Tulleb Tulleb - 1 year ago 124
Objective-C Question

AFNetworking accept all content types

I am doing a request operation to download every types of files from a server with AFHTTPRequestOperationManager.

At the moment, I am doing like this:

AFHTTPRequestOperationManager *manager = [[AFHTTPRequestOperationManager alloc] initWithBaseURL:baseURL];
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"image/jpeg", @"image/gif", @"image/png", @"application/pdf", ..., nil];

It is working nicely, but I would like to enable all content types possible to avoid missing some.

Is it possible to initiate the acceptable content types for every kind of existing content? Something like:

manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"*", nil];

Thank you.

Answer Source

just set acceptableContentTypes to nil.

the relevant code in AFNetworking looks like:

       if (self.acceptableContentTypes && ![self.acceptableContentTypes containsObject:[response MIMEType]]) {

if acceptableContentTypes is nil, then it doesn't bother checking, and just carries on downloading.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download