Ink / ios-picker

[DEPRECATED] The easiest way to import content into your application. http://filepicker.io
MIT License
226 stars 78 forks source link

Fix #100 where uploading fails when using AFNetworking 2.6.1 #107

Closed newyorkpizza closed 8 years ago

newyorkpizza commented 9 years ago

The behavior of AFHTTPRequestSerializer changed in AFNetworking 2.6.1 which causes the HTTPBody of requests to be discarded. Specifically, FPAPIClient.m was calling copying a request with AFHTTPRequestSerialized twice. The first time in -[FPAPIClient POST:parameters:usingOperationQueue:success:failure:], then again in the override in HTTPRequestOperationWithRequest:Success:failure.

Due to the change in behavior in AFNetworking (https://github.com/AFNetworking/AFNetworking/pull/2868/files) if a request has an empty query string, the new request created by AFHTTPRequestSerializer will also have an empty body, which is what was happening the second time that the request was copied with AFHTTPRequestSerializer.

It seems that FPAPIClient was relying on undefined behavior of the AFHTTPRequestSerializer initializer; namely that it would copy the HTTPBody if the HTTPBody was present.

Rather than try to get a fix made to AFNetworking, I think it's better to workaround the problem here by removing the override for HTTPRequestOperationWithRequest since the function seems to serve no purpose. The original commit 72f6fa0 does not shed any light on what exactly it's trying to accomplish with the user agent.

newyorkpizza commented 9 years ago

@dzana Hi Damian -- have you had a chance to take a look at my PRs or have a timeline when some of the open issues might be addressed?

dzana commented 9 years ago

@newyorkpizza The fix is good as a temporary solution. Please, remove changes from Podfile and Podfile.lock and I will accept the PR.

newyorkpizza commented 9 years ago

Cool, thanks for reviewing. I removed the changes to Podfile/Podfile.lock.