]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
c-hyper: initial support for "dumping" 1xx HTTP responses
authorDaniel Stenberg <daniel@haxx.se>
Sat, 14 Aug 2021 16:04:22 +0000 (18:04 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Fri, 20 Aug 2021 11:37:43 +0000 (13:37 +0200)
With the use hyper_request_on_informational()

Enable test 155 and 158

Closes #7597

lib/c-hyper.c
tests/data/DISABLED

index 57ac9af4be10cf30fc09b8431062d895f60a884a..5cb04bb3e121c594c36d62cc4d6894874299d1d0 100644 (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;
index 69e03ea8fcef370616c7584e722f021db41ac55a..01ee25772182472f6cda8d5410fa17cd5e35b552 100644 (file)
 # 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