AFImageRequestOperation tweaks #896

Closed
wants to merge 3 commits into
from

Conversation

Projects
None yet
2 participants

jam commented Apr 5, 2013

This pull request fixes a couple of issues I was having when using AFImageRequestOperation.

  • One of the servers my app tried to connect to was returning JPEG images with a content type of image/jpg. While technically incorrect, this caused the operation to fail, which isn't desirable behaviour. Unfortunately the server isn't one I control, otherwise I'd have made the change on the server side.
  • While attempting to subclass AFImageRequestOperation to include the invalid type, I noticed that imageRequestOperationWithRequest:imageProcessingBlock:success:failure: always returned AFImageRequestOperation instances, rather than instances of the current class (like the other request operation classes).

jam added some commits Apr 5, 2013

Use "self" when creating an AFImageRequestOperation object using the …
…convenience class method.

This enables using the method with subclasses.
Accept "image/jpg" as a valid content type for AFImageRequestOperation.
This is technically incorrect, as "image/jpg" is not a valid MIME type, but certain web servers return this type for JPEG images which causes AFImageRequestOperation to fail.
Contributor

mattt commented Apr 6, 2013

Thanks for submitting this pull request, @jam.

You're absolutely correct to fix the use of an explicit class instead of self in the class methods. Every other subclass in AFNetworking core does this except AFImageRequestOperation, until ab00b95. I credited you for the patch, which combines the two you had, and adds a cast, for consistency.

As for adding the acceptable content type, there is a class method for just that purpose (which means that you didn't have to subclass to begin with): AFHTTPRequestOperation +addAcceptableContentTypes:.

@mattt mattt closed this Apr 6, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment