NSURLConnection connection:willSendRequest:redirectResponse: bug
Originator: | cedric.luthi | ||
Number: | rdar://6700222 | Date Originated: | 19-Mar-2009 08:15 PM |
Status: | Closed | Resolved: | YES |
Product: | Mac OS X | Product Version: | 10.5.6 |
Classification: | Serious Bug | Reproducible: | Always |
Summary: NSURLConnection connection:willSendRequest:redirectResponse: delegate method does not properly cancel the connection Steps to Reproduce: 1. Compile the source code at http://pitaya.ch/radar/urlconnectionRedirect.m 2. Run with ./urlconnectionRedirect -cancelRedirect YES Expected Results: The connection:didReceiveData: and connectionDidFinishLoading: messages are sent to the ConnectionDelegate as documented in file:///Developer/Documentation/DocSets/com.apple.ADC_Reference_Library.CoreReference.docset/Contents/Resources/Documents/documentation/Cocoa/Reference/Foundation/Classes/NSURLConnection_Class/Reference/Reference.html#//apple_ref/doc/uid/20001697-BAJHIIDH "If the delegate wishes to cancel the redirect, it should call the connection object’s cancel method. Alternatively, the delegate method can return nil to cancel the redirect, and the connection will continue to process. This has special relevance in the case where redirectResponse is not nil. In this case, any data that is loaded for the connection will be sent to the delegate, and the delegate will receive a connectionDidFinishLoading or connection:didFailLoadingWithError: message, as appropriate." Actual Results: If nil is returned in connection:willSendRequest:redirectResponse: then the connection is terminated and no more message is sent to the delegate at all. Regression: Tested on Mac OS X 10.5.6. Notes: Steve Mykytyn had the exact same problem: http://www.cocoabuilder.com/archive/message/cocoa/2008/10/5/219452 The workaround suggested in reply to this message does not work. Also, if you close this bug as "Behaves correctly", I come to Cupertino and I kick your ass.
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!
Seems like the corresponding bug introduced by this fix was fixed in 10.5.8.
This has been fixed in 10.5.7, but it seems it also introduced a more severe bug, see http://stackoverflow.com/questions/916718/nsurlconnection-sendsynchronousrequest-and-nsstring-stringwithcontentsofurl-crash for details.