Search code examples
iosobjective-cxcodeafnetworkingcontent-type

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.


Solution

  • 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.