summaryrefslogtreecommitdiff
path: root/lib/http_proxy.c
diff options
context:
space:
mode:
authorJay Satiro <raysatiro@yahoo.com>2017-03-11 18:21:31 -0500
committerJay Satiro <raysatiro@yahoo.com>2017-03-11 18:22:42 -0500
commitec1d0ed1c14d1b2ed06d8914c19b3df2da575005 (patch)
treeeb6ef16bc243593a4b6ea4e2f2c17afcb582c0b3 /lib/http_proxy.c
parente08c0cd3275727978b69a1087bcebe0e38a5c9c9 (diff)
downloadcurl-ec1d0ed1c14d1b2ed06d8914c19b3df2da575005.tar.gz
http_proxy: Ignore TE and CL in CONNECT 2xx responses
A client MUST ignore any Content-Length or Transfer-Encoding header fields received in a successful response to CONNECT. "Successful" described as: 2xx (Successful). RFC 7231 4.3.6 Prior to this change such a case would cause an error. In some ways this bug appears to be a regression since c50b878. Prior to that libcurl may have appeared to function correctly in such cases by acting on those headers instead of causing an error. But that behavior was also incorrect. Bug: https://github.com/curl/curl/issues/1317 Reported-by: mkzero@users.noreply.github.com
Diffstat (limited to 'lib/http_proxy.c')
-rw-r--r--lib/http_proxy.c41
1 files changed, 21 insertions, 20 deletions
diff --git a/lib/http_proxy.c b/lib/http_proxy.c
index 7fde11dbb..a67328647 100644
--- a/lib/http_proxy.c
+++ b/lib/http_proxy.c
@@ -515,33 +515,34 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn,
}
else if(checkprefix("Content-Length:", line_start)) {
if(k->httpcode/100 == 2) {
- /* A server MUST NOT send any Transfer-Encoding or
- Content-Length header fields in a 2xx (Successful)
- response to CONNECT. (RFC 7231 section 4.3.6) */
- failf(data, "Content-Length: in %03d response",
+ /* A client MUST ignore any Content-Length or Transfer-Encoding
+ header fields received in a successful response to CONNECT.
+ "Successful" described as: 2xx (Successful). RFC 7231 4.3.6 */
+ infof(data, "Ignoring Content-Length in CONNECT %03d response\n",
k->httpcode);
- return CURLE_RECV_ERROR;
}
-
- cl = curlx_strtoofft(line_start +
- strlen("Content-Length:"), NULL, 10);
+ else {
+ cl = curlx_strtoofft(line_start +
+ strlen("Content-Length:"), NULL, 10);
+ }
}
else if(Curl_compareheader(line_start, "Connection:", "close"))
closeConnection = TRUE;
- else if(Curl_compareheader(line_start,
- "Transfer-Encoding:",
- "chunked")) {
+ else if(checkprefix("Transfer-Encoding:", line_start)) {
if(k->httpcode/100 == 2) {
- /* A server MUST NOT send any Transfer-Encoding or
- Content-Length header fields in a 2xx (Successful)
- response to CONNECT. (RFC 7231 section 4.3.6) */
- failf(data, "Transfer-Encoding: in %03d response", k->httpcode);
- return CURLE_RECV_ERROR;
+ /* A client MUST ignore any Content-Length or Transfer-Encoding
+ header fields received in a successful response to CONNECT.
+ "Successful" described as: 2xx (Successful). RFC 7231 4.3.6 */
+ infof(data, "Ignoring Transfer-Encoding in "
+ "CONNECT %03d response\n", k->httpcode);
+ }
+ else if(Curl_compareheader(line_start,
+ "Transfer-Encoding:", "chunked")) {
+ infof(data, "CONNECT responded chunked\n");
+ chunked_encoding = TRUE;
+ /* init our chunky engine */
+ Curl_httpchunk_init(conn);
}
- infof(data, "CONNECT responded chunked\n");
- chunked_encoding = TRUE;
- /* init our chunky engine */
- Curl_httpchunk_init(conn);
}
else if(Curl_compareheader(line_start, "Proxy-Connection:", "close"))
closeConnection = TRUE;