icanzilb/JSONModel — pull request #124 by j-h-a (2013-11-12 23:53:49+00:00)
Title: Incorrectly creating an error for 204 (no content) responses

When receiving a HTTP 204 response with no content, for example in response to a DELETE request it is valid to have no content. However in `JSONHTTPClient.m` on line 312 (line 316 in the updated code within this pull-request) it tries to convert the not-nil, but empty `responseData` object into a JSON object. This results in an error from the `JSONSerialization` class in trying to process the data and the error then incorrectly cascades up to the completion block.

I have fixed this on this branch, but I would like some scrutiny on the code before it is merged because it may affect other areas.

Marin:

Please can you check over these changes and have a think if this will break anything else. I have made two changes:
1. Don't try and process the data if it is empty.
2. Add `else` for the step 4.5 - if the JSON object creation fails in step 4 and creates an error, I don't think we want to try the same thing again in step 4.5.

My main concern, and reason for wanting extra scrutiny on this pull request, is because I would prefer to check the HTTP status is 204, but the HTTP response object is not available at this level in the call-stack. I'm not sure if there are other cases, where it might be invalid to return no content (non-nil, but empty response data) and this change could just gloss over them without creating an error object.

If you have any better ideas please let me know.