diff options
author | Desmond O. Chang <dochang@gmail.com> | 2016-04-28 17:33:25 +0800 |
---|---|---|
committer | Jay Satiro <raysatiro@yahoo.com> | 2017-03-12 01:32:33 -0500 |
commit | d2bcf1e3e247d116dc96bd3ea32056e3f089449c (patch) | |
tree | da6eb7bec914ef3a31883aa0ddb30ce33c5dde5e /lib | |
parent | ec1d0ed1c14d1b2ed06d8914c19b3df2da575005 (diff) |
url: add option CURLOPT_SUPPRESS_CONNECT_HEADERS
- Add new option CURLOPT_SUPPRESS_CONNECT_HEADERS to allow suppressing
proxy CONNECT response headers from the user callback functions
CURLOPT_HEADERFUNCTION and CURLOPT_WRITEFUNCTION.
- Add new tool option --suppress-connect-headers to expose
CURLOPT_SUPPRESS_CONNECT_HEADERS and allow suppressing proxy CONNECT
response headers from --dump-header and --include.
Assisted-by: Jay Satiro
Assisted-by: CarloCannas@users.noreply.github.com
Closes https://github.com/curl/curl/pull/783
Diffstat (limited to 'lib')
-rw-r--r-- | lib/http_proxy.c | 19 | ||||
-rw-r--r-- | lib/url.c | 3 | ||||
-rw-r--r-- | lib/urldata.h | 2 |
3 files changed, 14 insertions, 10 deletions
diff --git a/lib/http_proxy.c b/lib/http_proxy.c index a67328647..f09304a26 100644 --- a/lib/http_proxy.c +++ b/lib/http_proxy.c @@ -316,8 +316,6 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn, perline = 0; while(nread < BUFSIZE && keepon && !error) { - int writetype; - if(Curl_pgrsUpdate(conn)) return CURLE_ABORTED_BY_CALLBACK; @@ -419,19 +417,20 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn, Curl_debug(data, CURLINFO_HEADER_IN, line_start, (size_t)perline, conn); - /* send the header to the callback */ - writetype = CLIENTWRITE_HEADER; - if(data->set.include_header) - writetype |= CLIENTWRITE_BODY; + if(!data->set.suppress_connect_headers) { + /* send the header to the callback */ + int writetype = CLIENTWRITE_HEADER; + if(data->set.include_header) + writetype |= CLIENTWRITE_BODY; - result = Curl_client_write(conn, writetype, line_start, perline); + result = Curl_client_write(conn, writetype, line_start, perline); + if(result) + return result; + } data->info.header_size += (long)perline; data->req.headerbytecount += (long)perline; - if(result) - return result; - /* Newlines are CRLF, so the CR is ignored as the line isn't really terminated until the LF comes. Treat a following CR as end-of-headers as well.*/ @@ -2894,6 +2894,9 @@ CURLcode Curl_setopt(struct Curl_easy *data, CURLoption option, case CURLOPT_CONNECT_TO: data->set.connect_to = va_arg(param, struct curl_slist *); break; + case CURLOPT_SUPPRESS_CONNECT_HEADERS: + data->set.suppress_connect_headers = (0 != va_arg(param, long))?TRUE:FALSE; + break; default: /* unknown tag and its companion, just ignore: */ result = CURLE_UNKNOWN_OPTION; diff --git a/lib/urldata.h b/lib/urldata.h index 7402332d1..2dd7938e0 100644 --- a/lib/urldata.h +++ b/lib/urldata.h @@ -1756,6 +1756,8 @@ struct UserDefined { bool pipewait; /* wait for pipe/multiplex status before starting a new connection */ long expect_100_timeout; /* in milliseconds */ + bool suppress_connect_headers; /* suppress proxy CONNECT response headers + from user callbacks */ struct Curl_easy *stream_depends_on; bool stream_depends_e; /* set or don't set the Exclusive bit */ |