2
0

README.httpauth 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. 1. PUT/POST without a known auth to use (possibly no auth required):
  2. (When explicitly set to use a multi-pass auth when doing a POST/PUT,
  3. libcurl should immediately go the Content-Length: 0 bytes route to avoid
  4. the first send all data phase, step 2. If told to use a single-pass auth,
  5. goto step 3.)
  6. Issue the proper PUT/POST request immediately, with the correct
  7. Content-Length and Expect: headers.
  8. If a 100 response is received or the wait for one times out, start sending
  9. the request-body.
  10. If a 401 (or 407 when talking through a proxy) is received, then:
  11. If we have "more than just a little" data left to send, close the
  12. connection. Exactly what "more than just a little" means will have to be
  13. determined. Possibly the current transfer speed should be taken into
  14. account as well.
  15. NOTE: if the size of the POST data is less than MAX_INITIAL_POST_SIZE (when
  16. CURLOPT_POSTFIELDS is used), libcurl will send everything in one single
  17. write() (all request-headers and request-body) and thus it will
  18. unconditionally send the full post data here.
  19. 2. PUT/POST with multi-pass auth but not yet completely negotiated:
  20. Send a PUT/POST request, we know that it will be rejected and thus we claim
  21. Content-Length zero to avoid having to send the request-body. (This seems
  22. to be what IE does.)
  23. 3. PUT/POST as the last step in the auth negotiation, that is when we have
  24. what we believe is a completed negotiation:
  25. Send a full and proper PUT/POST request (again) with the proper
  26. Content-Length and a following request-body.
  27. NOTE: this may very well be the second (or even third) time the whole or at
  28. least parts of the request body is sent to the server. Since the data may
  29. be provided to libcurl with a callback, we need a way to tell the app that
  30. the upload is to be restarted so that the callback will provide data from
  31. the start again. This requires an API method/mechanism that libcurl
  32. doesn't have today. See below.
  33. Data Rewind
  34. It will be troublesome for some apps to deal with a rewind like this in all
  35. circumstances. I'm thinking for example when using 'curl' to upload data
  36. from stdin. If libcurl ends up having to rewind the reading for a request
  37. to succeed, of course a lack of this callback or if it returns failure, will
  38. cause the request to fail completely.
  39. The new callback is set with CURLOPT_IOCTLFUNCTION (in an attempt to add a
  40. more generic function that might be used for other IO-related controls in
  41. the future):
  42. curlioerr curl_ioctl(CURL *handle, curliocmd cmd, void *clientp);
  43. And in the case where the read is to be rewinded, it would be called with a
  44. cmd named CURLIOCMD_RESTARTREAD. The callback would then return CURLIOE_OK,
  45. if things are fine, or CURLIOE_FAILRESTART if not.
  46. Backwards Compatibility
  47. The approach used until now, that issues a HEAD on the given URL to trigger
  48. the auth negotiation could still be supported and encouraged, but it would
  49. be up to the app to first fetch a URL with GET/HEAD to negotiate on, since
  50. then a following PUT/POST wouldn't need to negotiate authentication and
  51. thus avoid double-sending data.
  52. Optionally, we keep the current approach if some option is set
  53. (CURLOPT_HEADBEFOREAUTH or similar), since it seems to work fairly well for
  54. POST on most servers.