httpc: fix content-length with a stream
The description of CURLOPT_UPLOAD [1] is confusing: If you use PUT to an HTTP 1.1 server, you can upload data without knowing the size before starting the transfer if you use chunked encoding. You enable this by adding a header like "Transfer-Encoding: chunked" with CURLOPT_HTTPHEADER. In fact, libcurl adds this header itself. Actually we need to avoid adding this header by libcurl with CURLOPT_INFILESIZE [2]. The CURLOPT_UPLOAD documentation has been updated [3]. 1. https://github.com/curl/curl/blob/555bacd6d522bcca497573765056354f4d5d7b33/docs/libcurl/opts/CURLOPT_UPLOAD.3 2. https://curl.se/libcurl/c/httpput.html 3. https://github.com/curl/curl/pull/11300 Closes #8744 NO_DOC=bugfix (cherry picked from commit e2e5ef4b)
Showing
- changelogs/unreleased/gh-8744-fix-chunked-with-content-length.md 4 additions, 0 deletions...ogs/unreleased/gh-8744-fix-chunked-with-content-length.md
- src/httpc.c 19 additions, 9 deletionssrc/httpc.c
- src/httpc.h 4 additions, 4 deletionssrc/httpc.h
- test/app-luatest/http_client_test.lua 46 additions, 2 deletionstest/app-luatest/http_client_test.lua
- test/app-luatest/httpd.py 18 additions, 3 deletionstest/app-luatest/httpd.py
Loading
Please register or sign in to comment