AFNetworking accept all content types AFNetworking accept all content types xcode xcode

AFNetworking accept all content types


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.


If anyone who finds this needs to add a specific image MIME type to the acceptable content list you can do the following:

#import <AFNetworking/UIImageView+AFNetworking.h>#import <AFNetworking/AFImageDownloader.h>AFImageResponseSerializer* serializer = (AFImageResponseSerializer*)[UIImageView sharedImageDownloader].sessionManager.responseSerializer;serializer.acceptableContentTypes = [serializer.acceptableContentTypes setByAddingObject:@"image/jpg"];

We needed to support "image/jpg" MIME types and this worked perfectly.