diff options
author | Daniel Stenberg <daniel@haxx.se> | 2021-06-07 13:07:37 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2021-06-07 23:54:42 +0200 |
commit | 7de85d271ae6fa77c9db8ee7521afedf134e9234 (patch) | |
tree | 6d03034ee74889906d043816e5fe002f09f95fba /lib | |
parent | 33812ad33d9782ba0ef79fa718fdde009e519e37 (diff) | |
download | curl-7de85d271ae6fa77c9db8ee7521afedf134e9234.tar.gz |
c-hyper: support CURLOPT_HEADER
When enabled, the headers are passed to the body write callback as well.
Like in test 500
Closes #7204
Diffstat (limited to 'lib')
-rw-r--r-- | lib/c-hyper.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/c-hyper.c b/lib/c-hyper.c index 4de93838d..73428c641 100644 --- a/lib/c-hyper.c +++ b/lib/c-hyper.c @@ -124,6 +124,7 @@ static int hyper_each_header(void *userdata, size_t len; char *headp; CURLcode result; + int writetype; Curl_dyn_reset(&data->state.headerb); if(name_len) { if(Curl_dyn_addf(&data->state.headerb, "%.*s: %.*s\r\n", @@ -145,7 +146,10 @@ static int hyper_each_header(void *userdata, Curl_debug(data, CURLINFO_HEADER_IN, headp, len); - result = Curl_client_write(data, CLIENTWRITE_HEADER, headp, len); + writetype = CLIENTWRITE_HEADER; + if(data->set.include_header) + writetype |= CLIENTWRITE_BODY; + result = Curl_client_write(data, writetype, headp, len); if(result) { data->state.hresult = CURLE_ABORTED_BY_CALLBACK; return HYPER_ITER_BREAK; @@ -219,6 +223,7 @@ static CURLcode status_line(struct Curl_easy *data, CURLcode result; size_t len; const char *vstr; + int writetype; vstr = http_version == HYPER_HTTP_VERSION_1_1 ? "1.1" : (http_version == HYPER_HTTP_VERSION_2 ? "2" : "1.0"); conn->httpversion = @@ -241,7 +246,10 @@ static CURLcode status_line(struct Curl_easy *data, len = Curl_dyn_len(&data->state.headerb); Curl_debug(data, CURLINFO_HEADER_IN, Curl_dyn_ptr(&data->state.headerb), len); - result = Curl_client_write(data, CLIENTWRITE_HEADER, + writetype = CLIENTWRITE_HEADER; + if(data->set.include_header) + writetype |= CLIENTWRITE_BODY; + result = Curl_client_write(data, writetype, Curl_dyn_ptr(&data->state.headerb), len); if(result) { data->state.hresult = CURLE_ABORTED_BY_CALLBACK; |