1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-24 17:18:48 -05:00

c-hyper: abort CONNECT response reading early on non 2xx responses

Fixes test 493

Closes #7209
This commit is contained in:
Daniel Stenberg 2021-06-08 23:30:57 +02:00
parent aeb064db03
commit c214a6a17b
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2
4 changed files with 27 additions and 10 deletions

View File

@ -186,6 +186,12 @@ static int hyper_body_chunk(void *userdata, const hyper_buf *chunk)
Curl_safefree(data->req.newurl); Curl_safefree(data->req.newurl);
} }
#endif #endif
if(data->state.hconnect &&
(data->req.httpcode/100 != 2)) {
done = TRUE;
result = CURLE_OK;
}
else
result = Curl_http_firstwrite(data, data->conn, &done); result = Curl_http_firstwrite(data, data->conn, &done);
if(result || done) { if(result || done) {
infof(data, "Return early from hyper_body_chunk\n"); infof(data, "Return early from hyper_body_chunk\n");

View File

@ -744,6 +744,8 @@ static CURLcode CONNECT(struct Curl_easy *data,
hyper_io_set_write(io, Curl_hyper_send); hyper_io_set_write(io, Curl_hyper_send);
conn->sockfd = tunnelsocket; conn->sockfd = tunnelsocket;
data->state.hconnect = TRUE;
/* create an executor to poll futures */ /* create an executor to poll futures */
if(!h->exec) { if(!h->exec) {
h->exec = hyper_executor_new(); h->exec = hyper_executor_new();

View File

@ -1411,6 +1411,7 @@ struct UrlState {
trailers_state trailers_state; /* whether we are sending trailers trailers_state trailers_state; /* whether we are sending trailers
and what stage are we at */ and what stage are we at */
#ifdef USE_HYPER #ifdef USE_HYPER
bool hconnect; /* set if a CONNECT request */
CURLcode hresult; /* used to pass return codes back from hyper callbacks */ CURLcode hresult; /* used to pass return codes back from hyper callbacks */
#endif #endif

View File

@ -1,6 +1,7 @@
<testcase> <testcase>
<info> <info>
<keywords> <keywords>
HTTP
HSTS HSTS
url_effective url_effective
</keywords> </keywords>
@ -9,7 +10,7 @@ url_effective
<reply> <reply>
# we use this as response to a CONNECT # we use this as response to a CONNECT
<data nocheck="yes"> <connect nocheck="yes">
HTTP/1.1 403 not OK at all HTTP/1.1 403 not OK at all
Date: Tue, 09 Nov 2010 14:49:00 GMT Date: Tue, 09 Nov 2010 14:49:00 GMT
Server: test-server/fake Server: test-server/fake
@ -18,7 +19,7 @@ Connection: close
Funny-head: yesyes Funny-head: yesyes
-foo- -foo-
</data> </connect>
</reply> </reply>
<client> <client>
@ -53,6 +54,13 @@ Proxy-Connection: Keep-Alive
</protocol> </protocol>
<stdout> <stdout>
HTTP/1.1 403 not OK at all
Date: Tue, 09 Nov 2010 14:49:00 GMT
Server: test-server/fake
Content-Length: 6
Connection: close
Funny-head: yesyes
https://this.hsts.example/%TESTNUMBER https://this.hsts.example/%TESTNUMBER
</stdout> </stdout>
# Proxy CONNECT aborted # Proxy CONNECT aborted