Skip to content

Commit

Permalink
c-hyper: initial support for "dumping" 1xx HTTP responses
Browse files Browse the repository at this point in the history
With the use hyper_request_on_informational()

Enable test 155 and 158

Closes #7597
  • Loading branch information
bagder committed Aug 20, 2021
1 parent 5b1c2dd commit f46b83f
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 4 deletions.
47 changes: 47 additions & 0 deletions lib/c-hyper.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 0 additions & 4 deletions tests/data/DISABLED
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f46b83f

Please sign in to comment.