NSURLConnection should handle HTTP errors with NSError
| Originator: | cedric.luthi | ||
| Number: | rdar://11544404 | Date Originated: | 28-May-2012 02:05 PM |
| Status: | Closed | Resolved: | Behaves correctly |
| Product: | iPhone SDK | Product Version: | 5.1 |
| Classification: | Enhancement | Reproducible: | Not Applicable |
Summary: Currently, a NSURLConnection instance will send the connection:didReceiveData: and connectionDidFinishLoading: messages to its delegate, even if the HTTP status code is greater or equal to 400. The Hypertext Transfer Protocol (RFC 2616) states that 4xx and 5xx status codes are respectively client errors and server errors. I think NSURLConnection should instead send the connection:didFailWithError: message to its delegate with an appropriate NSError of the HTTPErrorDomain. The HTTPErrorDomain should be added to the API for this purpose. Steps to Reproduce: Expected Results: Actual Results: Not applicable. This bug report is about a suggested enhancement to the NSURLConnection API. Regression: NSURLConnection has never sent its delegate the connection:didFailWithError: when encountering a HTTP level error. Notes: I wrote CLURLConnection, an NSURLConnection subclass to workaround this behavior: https://github.com/0xced/CLURLConnection
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!
01-Nov-2012 02:26 PM Apple Developer Bug Reporting Team
Engineering has determined that this issue behaves as intended based on the following information:
-didReceiveResponse: is the appropriate place to take action on server errors. -didFail: is used to indicate a system error, not a messaging error.
I duped that as 11544632