Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 375
Tulleb Avatar asked Mar 11 '15 09:03

Tulleb


1 Answers

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.

like image 101
Confused Vorlon Avatar answered Sep 21 '22 11:09

Confused Vorlon