Mil0R3
Mil0R3

Reputation: 3956

AFNetworking set image without extension

There is a method in AFNetworking that can set image conveniently:

 - (void)setImageWithURL:(NSURL *)url 
   placeholderImage:(UIImage *)placeholderImage

but if the url image have no extension(like http://static.qyer.com/album/user/330/21/QkpVQBsHaA/670), there are some problems,sometimes the image can be displayed exactly some times it is not displayed.

I found a method

  [AFImageRequestOperation addAcceptableContentTypes:<#(NSSet *)contentTypes#>];

how should I set the contentTypes?

Upvotes: 1

Views: 604

Answers (1)

mattt
mattt

Reputation: 19544

If you curl the URL provided, you can see the problem:

curl -i -X HEAD http://static.qyer.com/album/user/330/21/QkpVQBsHaA/670

HTTP/1.0 200 OK
Server: nginx/1.0.11
Date: Fri, 29 Mar 2013 02:03:24 GMT
Content-Type: application/octer-stream
Last-Modified: Tue, 19 Mar 2013 09:40:23 GMT
ETag: "53430075-9814c-4d843e4fc6fc0"
Accept-Ranges: bytes
Content-Length: 622924
Powered-By-ChinaCache: MISS from 060531Q354
Powered-By-ChinaCache: MISS from 060532235y
Connection: close

Content-Type: application/octer-stream (which is, strangely, a misspelling of application/octet-stream), is not a valid image mime type. If you have any control over the server, I would strongly recommend you fix this to send real mime types—for the sake of everyone accessing the CDN.

Otherwise, I would recommend you add */* to the list of acceptable content types. This should accept anything thrown at it. You can also manually specify any content types you might expect the CDN to serve, including application/octer-stream.

Upvotes: 2

Related Questions