From: Daniel Stenberg Date: Tue, 8 Aug 2023 11:19:37 +0000 (+0200) Subject: c-hyper: adjust the hyper to curlcode conversion X-Git-Tag: curl-8_3_0~188 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=850f6c79e8a8cc3cc5e165acefa4ca6fe6117498;p=thirdparty%2Fcurl.git c-hyper: adjust the hyper to curlcode conversion Closes #11621 --- diff --git a/lib/c-hyper.c b/lib/c-hyper.c index 0b9d9ab478..a47a03e126 100644 --- a/lib/c-hyper.c +++ b/lib/c-hyper.c @@ -416,14 +416,26 @@ CURLcode Curl_hyper_stream(struct Curl_easy *data, size_t errlen = hyper_error_print(hypererr, errbuf, sizeof(errbuf)); hyper_code code = hyper_error_code(hypererr); failf(data, "Hyper: [%d] %.*s", (int)code, (int)errlen, errbuf); - if(code == HYPERE_ABORTED_BY_CALLBACK) + switch(code) { + case HYPERE_ABORTED_BY_CALLBACK: result = CURLE_OK; - else if((code == HYPERE_UNEXPECTED_EOF) && !data->req.bytecount) - result = CURLE_GOT_NOTHING; - else if(code == HYPERE_INVALID_PEER_MESSAGE) + break; + case HYPERE_UNEXPECTED_EOF: + if(!data->req.bytecount) + result = CURLE_GOT_NOTHING; + else + result = CURLE_RECV_ERROR; + break; + case HYPERE_INVALID_PEER_MESSAGE: + /* bump headerbytecount to avoid the count remaining at zero and + appearing to not having read anything from the peer at all */ + data->req.headerbytecount++; result = CURLE_UNSUPPORTED_PROTOCOL; /* maybe */ - else + break; + default: result = CURLE_RECV_ERROR; + break; + } } *done = TRUE; hyper_error_free(hypererr);