From 8a38c72c48cdc75e21aa1d13235215783115007f Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 2 Aug 2006 18:18:47 +0000 Subject: [PATCH] Mark Lentczner fixed how libcurl was not properly doing chunked encoding if the header "Transfer-Encoding: chunked" was set by the application. http://curl.haxx.se/bug/view.cgi?id=1531838 --- CHANGES | 5 +++++ RELEASE-NOTES | 3 ++- lib/http.c | 31 +++++++++---------------------- 3 files changed, 16 insertions(+), 23 deletions(-) diff --git a/CHANGES b/CHANGES index 23e7ccbdb..33b9b3d22 100644 --- a/CHANGES +++ b/CHANGES @@ -6,6 +6,11 @@ Changelog +Daniel (2 August 2006) +- Mark Lentczner fixed how libcurl was not properly doing chunked encoding + if the header "Transfer-Encoding: chunked" was set by the application. + http://curl.haxx.se/bug/view.cgi?id=1531838 + Daniel (1 August 2006) - Maciej Karpiuk fixed a crash that would occur if we passed Curl_strerror() an unknown error number on glibc systems. diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 99722ccc4..a447d6a82 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -24,6 +24,7 @@ This release includes the following changes: This release includes the following bugfixes: + o chunked encoding when custom header "Transfer-Encoding: chunked" is set o Curl_strerror() crash on unknown errors o changing Content-Type when doing formposts o added CURL_EXTERN to a few recent multi functions that lacked them @@ -51,6 +52,6 @@ advice from friends like these: Dan Fandrich, Peter Silva, Arve Knudsen, Michael Wallner, Toshiyuki Maezawa, Ingmar Runge, Ates Goral, David McCreedy, Jari Sundell, Georg Horn, Gisle Vanem, Yang Tse, Michael Jerris, Dan Nelson, Yves Lejeune, - Maciej Karpiuk + Maciej Karpiuk, Mark Lentczner Thanks! (and sorry if I forgot to mention someone) diff --git a/lib/http.c b/lib/http.c index f4898fcd5..512b17312 100644 --- a/lib/http.c +++ b/lib/http.c @@ -1684,30 +1684,17 @@ CURLcode Curl_http(struct connectdata *conn, bool *done) return CURLE_OUT_OF_MEMORY; } - if(!conn->bits.upload_chunky && (httpreq != HTTPREQ_GET)) { - /* not a chunky transfer yet, but data is to be sent */ - ptr = checkheaders(data, "Transfer-Encoding:"); - if(ptr) { - /* Some kind of TE is requested, check if 'chunked' is chosen */ - conn->bits.upload_chunky = - Curl_compareheader(ptr, "Transfer-Encoding:", "chunked"); - te = ""; - } + ptr = checkheaders(data, "Transfer-Encoding:"); + if(ptr) { + /* Some kind of TE is requested, check if 'chunked' is chosen */ + conn->bits.upload_chunky = + Curl_compareheader(ptr, "Transfer-Encoding:", "chunked"); } - else if(conn->bits.upload_chunky) { - /* RFC2616 section 4.4: - Messages MUST NOT include both a Content-Length header field and a - non-identity transfer-coding. If the message does include a non- - identity transfer-coding, the Content-Length MUST be ignored. */ - - if(!checkheaders(data, "Transfer-Encoding:")) { + else { + if (httpreq == HTTPREQ_GET) + conn->bits.upload_chunky = FALSE; + if(conn->bits.upload_chunky) te = "Transfer-Encoding: chunked\r\n"; - } - else { - te = ""; - conn->bits.upload_chunky = FALSE; /* transfer-encoding was disabled, - so don't chunkify this! */ - } } Curl_safefree(conn->allocptr.host);