summaryrefslogtreecommitdiff
path: root/lib/http_proxy.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2021-05-27 16:50:24 +0200
committerDaniel Stenberg <daniel@haxx.se>2021-05-27 18:13:45 +0200
commitd3e0f20fea6b54678810baaf5599e62f8b70ad20 (patch)
tree3dcb4259ee7b30a11f60019a1d05e151897bcfcb /lib/http_proxy.c
parent23b99fc94c5a872760c4177ee15b5e394a38e280 (diff)
downloadcurl-d3e0f20fea6b54678810baaf5599e62f8b70ad20.tar.gz
http_proxy: deal with non-200 CONNECT response with Hyper
Makes test 94 and 95 work Closes #7141
Diffstat (limited to 'lib/http_proxy.c')
-rw-r--r--lib/http_proxy.c35
1 files changed, 32 insertions, 3 deletions
diff --git a/lib/http_proxy.c b/lib/http_proxy.c
index a3a62c1ca..cf408400e 100644
--- a/lib/http_proxy.c
+++ b/lib/http_proxy.c
@@ -243,11 +243,11 @@ static CURLcode CONNECT_host(struct Curl_easy *data,
return CURLE_OK;
}
+#ifndef USE_HYPER
static CURLcode CONNECT(struct Curl_easy *data,
int sockindex,
const char *hostname,
int remote_port)
-#ifndef USE_HYPER
{
int subversion = 0;
struct SingleRequest *k = &data->req;
@@ -702,6 +702,10 @@ static CURLcode CONNECT(struct Curl_easy *data,
}
#else
/* The Hyper version of CONNECT */
+static CURLcode CONNECT(struct Curl_easy *data,
+ int sockindex,
+ const char *hostname,
+ int remote_port)
{
struct connectdata *conn = data->conn;
struct hyptransfer *h = &data->hyp;
@@ -875,7 +879,6 @@ static CURLcode CONNECT(struct Curl_easy *data,
goto error;
if(!done)
break;
- fprintf(stderr, "done\n");
s->tunnel_state = TUNNEL_COMPLETE;
if(h->exec) {
hyper_executor_free(h->exec);
@@ -897,6 +900,33 @@ static CURLcode CONNECT(struct Curl_easy *data,
} while(data->req.newurl);
result = CURLE_OK;
+ if(s->tunnel_state == TUNNEL_COMPLETE) {
+ data->info.httpproxycode = data->req.httpcode;
+ if(data->info.httpproxycode/100 != 2) {
+ if(conn->bits.close && data->req.newurl) {
+ conn->bits.proxy_connect_closed = TRUE;
+ infof(data, "Connect me again please\n");
+ connect_done(data);
+ }
+ else {
+ free(data->req.newurl);
+ data->req.newurl = NULL;
+ /* failure, close this connection to avoid re-use */
+ streamclose(conn, "proxy CONNECT failure");
+ Curl_closesocket(data, conn, conn->sock[sockindex]);
+ conn->sock[sockindex] = CURL_SOCKET_BAD;
+ }
+
+ /* to back to init state */
+ s->tunnel_state = TUNNEL_INIT;
+
+ if(!conn->bits.proxy_connect_closed) {
+ failf(data, "Received HTTP code %d from proxy after CONNECT",
+ data->req.httpcode);
+ result = CURLE_RECV_ERROR;
+ }
+ }
+ }
error:
free(host);
free(hostheader);
@@ -917,7 +947,6 @@ static CURLcode CONNECT(struct Curl_easy *data,
}
return result;
}
-
#endif
void Curl_connect_free(struct Curl_easy *data)