]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
hyper: propagate errors back up from read callbacks
authorDaniel Stenberg <daniel@haxx.se>
Wed, 16 Jun 2021 08:52:21 +0000 (10:52 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 17 Jun 2021 06:19:31 +0000 (08:19 +0200)
Makes test 513 work with hyper

Closes #7266

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

index e3fd26c1ace79aad2e64b7715bed2f1b1e56aca4..adbd3fe76ec0a7ea4b1a27b8dd902c4459a8e20f 100644 (file)
@@ -566,8 +566,10 @@ static int uploadpostfields(void *userdata, hyper_context *ctx,
                                      (size_t)data->req.p.http->postsize);
     if(copy)
       *chunk = copy;
-    else
+    else {
+      data->state.hresult = CURLE_OUT_OF_MEMORY;
       return HYPER_POLL_ERROR;
+    }
     /* increasing the writebytecount here is a little premature but we
        don't know exactly when the body is sent*/
     data->req.writebytecount += (size_t)data->req.p.http->postsize;
@@ -585,8 +587,10 @@ static int uploadstreamed(void *userdata, hyper_context *ctx,
   CURLcode result =
     Curl_fillreadbuffer(data, data->set.upload_buffer_size, &fillcount);
   (void)ctx;
-  if(result)
+  if(result) {
+    data->state.hresult = result;
     return HYPER_POLL_ERROR;
+  }
   if(!fillcount)
     /* done! */
     *chunk = NULL;
@@ -594,8 +598,10 @@ static int uploadstreamed(void *userdata, hyper_context *ctx,
     hyper_buf *copy = hyper_buf_copy((uint8_t *)data->state.ulbuf, fillcount);
     if(copy)
       *chunk = copy;
-    else
+    else {
+      data->state.hresult = CURLE_OUT_OF_MEMORY;
       return HYPER_POLL_ERROR;
+    }
     /* increasing the writebytecount here is a little premature but we
        don't know exactly when the body is sent*/
     data->req.writebytecount += fillcount;
@@ -952,6 +958,8 @@ CURLcode Curl_http(struct Curl_easy *data, bool *done)
     hyper_code code = hyper_error_code(hypererr);
     failf(data, "Hyper: [%d] %.*s", (int)code, (int)errlen, errbuf);
     hyper_error_free(hypererr);
+    if(data->state.hresult)
+      return data->state.hresult;
   }
   return CURLE_OUT_OF_MEMORY;
 }
index b114c0b427e432ec4c3d9c892c39caa84523b178..41bc6f41871cef5d241f08a4ba42256c63c61651 100644 (file)
@@ -55,7 +55,6 @@
 357
 358
 359
-513
 547
 551
 552
index 968da4fb75390a7590b86f1e5c9735e09c2f2384..df0a96260a07dfae32081ec5c606a0b4e34c70df 100644 (file)
@@ -34,12 +34,14 @@ http://%HOSTIP:%HTTPPORT/%TESTNUMBER
 # Verify data after the test has been "shot"
 <verify>
 <protocol>
+%if !hyper
 POST /%TESTNUMBER HTTP/1.1\r
 Host: %HOSTIP:%HTTPPORT\r
 Accept: */*\r
 Content-Length: 1\r
 Content-Type: application/x-www-form-urlencoded\r
 \r
+%endif
 </protocol>
 # 42 - aborted by callback
 <errorcode>