NSURLConnection should support "Expect: 100-continue" header

Originator:ddribin
Number:rdar://5188833 Date Originated:08-May-2007 01:31 PM
Status:Open Resolved:
Product: Product Version:
Classification: Reproducible:
 
Summary: 

NSURLConnection does not support the "Expect: 100-continue" header.  Without this header, uploading a file using POST to server that uses HTTP authentication results in uploads taking twice as long as necessary.

  <http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.20>

  <http://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html#sec8.2.3>

Without 100-continue, the HTTP client uploads the whole file, only to get a 401 response from the server.  The client then needs to upload the file *again*, this time with the proper credentials.  With 100-continue, the HTTP client pauses before sending the body.  This allows the server to respond with a 401 before 

Steps to Reproduce: 

Upload a file using NSURLConnection and POST against a server with HTTP authentication.  I've attached a small PHP app that contains a form and PHP script to accept the upload.  The script, `private/uploader.php` is protected with the username "foo", password "bar".  A small Cocoa app that POSTs to "private/uploader.php" using NSURLConnection is required.

Expected Results: 

While running a network trace, such as tcpdump or Wireshark, the upload should only occur once, with the first upload interrupted with a 401 response, instead of a 100 Continue.

Actual Results: 

The network trace shows the file uploaded twice.  The first one is discarded and wastedful since the server responds with a 401.

Regression: 

N/A

Notes: 

Other HTTP client libraries like libcurl and .Net support 100-continue.  However, they usually allow a way to disable this behavior in case a program needs to work around a buggy server that does not implement HTTP 1.1 correctly.

  <http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTPOST>

  <http://msdn2.microsoft.com/en-us/library/system.net.servicepoint.expect100continue.aspx>


'php-upload.tar.gz' was successfully uploaded

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!