4
votes

When an HTTP request includes

Expect: 100-continue

in the header, a special protocol is enabled. It's complicated, but useful.

In the experiments we've run, the iOS 8 version of NSURLSession does not seem to send this expect header by default. We're still exploring whether including it explicitly works.

The only reference we can find in Apple documentation claims that 100-continue will work is for the predecessor to NSURLSession, which isNSURLConnection. It says

If you are uploading data to a compatible server, the URL loading system also supports the 100 (Continue) HTTP status code, which allows an upload to continue where it left off in the event of an authentication error or other failure†. To enable support for upload continuation, set the Expect: header on the request object to 100-continue.

What I'd like help with

In order of preference:

  1. Detailed information on how this works from Apple.
  2. Any information on how this works on iOS from anybody.

I'm definitely interested in knowing how this works on OS X as well.


† I'm not sure that's even a good description of what should be happening with 100-continue, because IIUC one point is that the body of the request is large, and you'd rather send the request header, get it pre-approved by the server, and then start sending the body.


Appendix

This is a useful link discussing the vagaries of how 100-continue should be handled.

This is a decently useful dialog I found on a github issue, about trying this using NSURLConnection on OS X.

1

1 Answers

1
votes

Yes, it explicitly works if you set the header yourself. In fact, download tasks use it automatically without the need to set the header, if memory serves. By default, IIRC, other tasks do not, under the assumption that requests might not be idempotent.