c-hyper: initial support for "dumping" 1xx HTTP responses

With the use hyper_request_on_informational()

Enable test 155 and 158

Closes #7597
This commit is contained in:
Daniel Stenberg 2021-08-14 18:04:22 +02:00
parent 5b1c2dd1db
commit f46b83fc94
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
2 changed files with 47 additions and 4 deletions

View file

@ -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;

View file

@ -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