글꼴 다람쥐 API의 다른 모든 끝점을 사용할 수 있지만 ZIP 글꼴 킷을 반환하는 끝점을 가져올 때마다 Request failed: unacceptable content-type: "application/x-zip"
헤더를 내가 추가 acceptableContentTypes = @"text/html",@"application/x-zip"
각, XML, JSON 및 HTTP에 응답 시리얼을 설정하려고했기 때문에,AFNetworking이 포함 된 .zip 파일을 다운로드 할 수 없습니다.
status code: 200, headers {
Connection = \"keep-alive\";
\"Content-Disposition\" = \"attachment; filename=\\\"1942-report-fontfacekit.zip\\\"\";
\"Content-Length\" = 284695;
\"Content-Transfer-Encoding\" = binary;
\"Content-Type\" = \"\\\"application/x-zip\\\"\";
Date = \"Fri, 11 Apr 2014 23:21:37 GMT\";
Expires = 0;\n Pragma = \"no-cache\";
Server = \"nginx admin\";
\"Set-Cookie\" = \"admin_rm=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/; domain=www.fontsquirrel.com, sitetoken=9e7e8c6f53ffe68791fa9e6a2531fe88; expires=Mon, 08-Apr-2024 23:21:37 GMT; path=/; domain=www.fontsquirrel.com, tracker=b13703d93358d65f09306b1b09d6e072; path=/; domain=www.fontsquirrel.com\";
\"X-Cache\" = \"HIT from Backend\";
\"X-Powered-By\" = \"PHP/5.3.23\";
\"X-UA-Compatible\" = \"IE=Edge,chrome=1\";
는 나에게 정말 이상한 모습. 내가 뭔가 잘못하고 있는지 또는 API 개발자에게 뭔가 잘못 될 수 있는지 명확히해야하는지 잘 모르겠습니다. 나는 크롬과 컬에서 정확히 동일한 GET 요청을 할 수 있으며 둘 다 작동한다.
- 편집, 추가 코드 조각 // 초기화
+(instancetype)sharedManager {
static APIManager *manager;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
manager = [[APIManager alloc] initWithBaseURL:[NSURL URLWithString:@"http://www.fontsquirrel.com/"]];
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/html",@"application/x-zip",nil];
});
return manager;
}
// 고려 될
-(AFHTTPRequestOperation*)downloadFontFamily:(FontFamily*)fontFamily withBlock:(void(^)(UIFont *UIFont, NSError *error))callback {
return [self GET:FORMAT(@"fontfacekit/%@",fontFamily.familyURLName) parameters:nil success:^(AFHTTPRequestOperation *operation,
id responseObject) {
NSLog(@"%@%@",[responseObject class],responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"FAIL %@\n%@",error.localizedDescription,error.userInfo);
}];
}
질문을 편집하여 다운로드 및 설정하려는 코드를 표시 할 수 있습니까? – Paulw11
@ Paulw11 코드 추가 – mcornell