diff options
author | Daniel Stenberg <daniel@haxx.se> | 2021-08-14 18:04:22 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2021-08-20 13:37:43 +0200 |
commit | f46b83fc94148efd363a457b4631b99e7c13baec (patch) | |
tree | 5590f8b793b53945cf0940e13afe271107af563e | |
parent | 5b1c2dd1db6465f4664becc9a8b686e4151fae68 (diff) | |
download | curl-f46b83fc94148efd363a457b4631b99e7c13baec.tar.gz |
c-hyper: initial support for "dumping" 1xx HTTP responses
With the use hyper_request_on_informational()
Enable test 155 and 158
Closes #7597
-rw-r--r-- | lib/c-hyper.c | 47 | ||||
-rw-r--r-- | tests/data/DISABLED | 4 |
2 files changed, 47 insertions, 4 deletions
diff --git a/lib/c-hyper.c b/lib/c-hyper.c index 57ac9af4b..5cb04bb3e 100644 --- a/lib/c-hyper.c +++ b/lib/c-hyper.c @@ -723,6 +723,48 @@ static CURLcode cookies(struct Curl_easy *data, return result; } +/* called on 1xx responses */ +static void http1xx_cb(void *arg, struct hyper_response *resp) +{ + struct Curl_easy *data = (struct Curl_easy *)arg; + hyper_headers *headers = NULL; + CURLcode result = CURLE_OK; + uint16_t http_status; + int http_version; + const uint8_t *reasonp; + size_t reason_len; + + infof(data, "Got HTTP 1xx informational"); + + http_status = hyper_response_status(resp); + http_version = hyper_response_version(resp); + reasonp = hyper_response_reason_phrase(resp); + reason_len = hyper_response_reason_phrase_len(resp); + + result = status_line(data, data->conn, + http_status, http_version, reasonp, reason_len); + if(!result) { + headers = hyper_response_headers(resp); + if(!headers) { + failf(data, "hyperstream: couldn't get 1xx response headers"); + result = CURLE_RECV_ERROR; + } + } + data->state.hresult = result; + + if(!result) { + /* the headers are already received */ + hyper_headers_foreach(headers, hyper_each_header, data); + /* this callback also sets data->state.hresult on error */ + + if(empty_header(data)) + result = CURLE_OUT_OF_MEMORY; + } + + if(data->state.hresult) + infof(data, "ERROR in 1xx, bail out!"); +} + /* * Curl_http() gets called from the generic multi_do() function when a HTTP * request is to be performed. This creates and sends a properly constructed @@ -746,6 +788,7 @@ CURLcode Curl_http(struct Curl_easy *data, bool *done) Curl_HttpReq httpreq; bool h2 = FALSE; const char *te = NULL; /* transfer-encoding */ + hyper_code rc; /* Always consider the DO phase done after this function call, even if there may be parts of the request that is not yet sent, since we can deal with @@ -872,6 +915,10 @@ CURLcode Curl_http(struct Curl_easy *data, bool *done) goto error; } + rc = hyper_request_on_informational(req, http1xx_cb, data); + if(rc) + return CURLE_OUT_OF_MEMORY; + result = Curl_http_body(data, conn, httpreq, &te); if(result) return result; diff --git a/tests/data/DISABLED b/tests/data/DISABLED index 69e03ea8f..01ee25772 100644 --- a/tests/data/DISABLED +++ b/tests/data/DISABLED @@ -36,18 +36,14 @@ # hyper support remains EXPERIMENTAL as long as there's a test number # listed below %if hyper -155 -158 206 207 209 213 217 -246 262 265 266 -281 287 319 326 |