authneg: add Content-Length:0 while negotiating auth #1242

Closed
wants to merge 1 commit into
from

Projects

None yet

5 participants

@frenche
Contributor
frenche commented Feb 3, 2017

Even if the user supplied custom content-length header it
should be set to 0 for both HTTPREQ_POST and HTTPREQ_PUT flows.
This is what we do already in HTTPREQ_POST_FORM and what we
did in the HTTPREQ_POST case prior to commit:
afd288b

Otherwise, if the user set custom header we'd end up skipping
the content-length header altogether.

Signed-off-by: Isaac Boukris iboukris@gmail.com
Reported-by: Hölzl, Dominik Dominik.Hoelzl@fabasoft.com

@frenche frenche authneg: add Content-Length:0 while negotiating auth
Even if the user supplied custom content-length header it
should be set to 0 for both HTTPREQ_POST and HTTPREQ_PUT flows.
This is what we do already in HTTPREQ_POST_FORM and what we
did in the HTTPREQ_POST case prior to commit:
afd288b

Otherwise, if the user set custom header we'd end up skipping
the content-length header altogether.

Signed-off-by: Isaac Boukris <iboukris@gmail.com>
Reported-by: Hölzl, Dominik <Dominik.Hoelzl@fabasoft.com>
cb7d90c
@frenche
Contributor
frenche commented Feb 5, 2017

Hi, here is a small reproducer based on Dominik's example on mailing-list (notice CL missing).

#include <curl/curl.h>

int main(int argc, char *argv[])
{
  CURLcode ret;
  CURL *hnd;

  hnd = curl_easy_init();
  curl_easy_setopt(hnd, CURLOPT_URL, "http://localhost/");
  curl_easy_setopt(hnd, CURLOPT_USERPWD, "x:y");
  curl_easy_setopt(hnd, CURLOPT_HTTPAUTH, CURLAUTH_NTLM);
  curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L);

  curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "a=b");

  struct curl_slist *headers = NULL;
  headers = curl_slist_append(headers, "Content-Length: 3");
  curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);

  ret = curl_easy_perform(hnd);

  curl_easy_cleanup(hnd);

  return ret;
}
@bagder
bagder approved these changes Feb 7, 2017 View changes
@jay jay added a commit that closed this pull request Feb 17, 2017
@frenche @jay frenche + jay http: fix missing 'Content-Length: 0' while negotiating auth
- While negotiating auth during PUT/POST if a user-specified
  Content-Length header is set send 'Content-Length: 0'.

This is what we do already in HTTPREQ_POST_FORM and what we did in the
HTTPREQ_POST case (regression since afd288b).

Prior to this change no Content-Length header would be sent in such a
case.

Bug: https://curl.haxx.se/mail/lib-2017-02/0006.html
Reported-by: Dominik Hölzl

Closes #1242
13e3a18
@jay jay closed this in 13e3a18 Feb 17, 2017
@jay
Member
jay commented Feb 17, 2017

Thanks Isaac I landed this with some tests and a modified commit message.

@frenche
Contributor
frenche commented Feb 17, 2017

Great, thank you all!

@dhoelzl
dhoelzl commented Feb 22, 2017

Thank you for the quick response and fixing the problem!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment