mirror of
https://github.com/moparisthebest/curl
synced 2024-08-13 17:03:50 -04:00
http_proxy: use enum with state names for 'keepon'
To make the code clearer, change the 'keepon' from an int to an enum with better state names. Reported-by: Niranjan Hasabnis Bug: https://curl.se/mail/lib-2020-11/0026.html Closes #6193
This commit is contained in:
parent
7ae59838f0
commit
c49d205ae0
@ -167,7 +167,7 @@ static CURLcode connect_init(struct connectdata *conn, bool reinit)
|
|||||||
Curl_dyn_reset(&s->rcvbuf);
|
Curl_dyn_reset(&s->rcvbuf);
|
||||||
}
|
}
|
||||||
s->tunnel_state = TUNNEL_INIT;
|
s->tunnel_state = TUNNEL_INIT;
|
||||||
s->keepon = TRUE;
|
s->keepon = KEEPON_CONNECT;
|
||||||
s->cl = 0;
|
s->cl = 0;
|
||||||
s->close_connection = FALSE;
|
s->close_connection = FALSE;
|
||||||
return CURLE_OK;
|
return CURLE_OK;
|
||||||
@ -339,7 +339,7 @@ static CURLcode CONNECT(struct connectdata *conn,
|
|||||||
return CURLE_ABORTED_BY_CALLBACK;
|
return CURLE_ABORTED_BY_CALLBACK;
|
||||||
|
|
||||||
if(result) {
|
if(result) {
|
||||||
s->keepon = FALSE;
|
s->keepon = KEEPON_DONE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if(gotbytes <= 0) {
|
else if(gotbytes <= 0) {
|
||||||
@ -353,11 +353,11 @@ static CURLcode CONNECT(struct connectdata *conn,
|
|||||||
error = SELECT_ERROR;
|
error = SELECT_ERROR;
|
||||||
failf(data, "Proxy CONNECT aborted");
|
failf(data, "Proxy CONNECT aborted");
|
||||||
}
|
}
|
||||||
s->keepon = FALSE;
|
s->keepon = KEEPON_DONE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(s->keepon > TRUE) {
|
if(s->keepon == KEEPON_IGNORE) {
|
||||||
/* This means we are currently ignoring a response-body */
|
/* This means we are currently ignoring a response-body */
|
||||||
|
|
||||||
if(s->cl) {
|
if(s->cl) {
|
||||||
@ -365,7 +365,7 @@ static CURLcode CONNECT(struct connectdata *conn,
|
|||||||
and make sure to break out of the loop when we're done! */
|
and make sure to break out of the loop when we're done! */
|
||||||
s->cl--;
|
s->cl--;
|
||||||
if(s->cl <= 0) {
|
if(s->cl <= 0) {
|
||||||
s->keepon = FALSE;
|
s->keepon = KEEPON_DONE;
|
||||||
s->tunnel_state = TUNNEL_COMPLETE;
|
s->tunnel_state = TUNNEL_COMPLETE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -383,7 +383,7 @@ static CURLcode CONNECT(struct connectdata *conn,
|
|||||||
if(r == CHUNKE_STOP) {
|
if(r == CHUNKE_STOP) {
|
||||||
/* we're done reading chunks! */
|
/* we're done reading chunks! */
|
||||||
infof(data, "chunk reading DONE\n");
|
infof(data, "chunk reading DONE\n");
|
||||||
s->keepon = FALSE;
|
s->keepon = KEEPON_DONE;
|
||||||
/* we did the full CONNECT treatment, go COMPLETE */
|
/* we did the full CONNECT treatment, go COMPLETE */
|
||||||
s->tunnel_state = TUNNEL_COMPLETE;
|
s->tunnel_state = TUNNEL_COMPLETE;
|
||||||
}
|
}
|
||||||
@ -437,7 +437,7 @@ static CURLcode CONNECT(struct connectdata *conn,
|
|||||||
/* If we get a 407 response code with content length
|
/* If we get a 407 response code with content length
|
||||||
when we have no auth problem, we must ignore the
|
when we have no auth problem, we must ignore the
|
||||||
whole response-body */
|
whole response-body */
|
||||||
s->keepon = 2;
|
s->keepon = KEEPON_IGNORE;
|
||||||
|
|
||||||
if(s->cl) {
|
if(s->cl) {
|
||||||
infof(data, "Ignore %" CURL_FORMAT_CURL_OFF_T
|
infof(data, "Ignore %" CURL_FORMAT_CURL_OFF_T
|
||||||
@ -465,7 +465,7 @@ static CURLcode CONNECT(struct connectdata *conn,
|
|||||||
if(r == CHUNKE_STOP) {
|
if(r == CHUNKE_STOP) {
|
||||||
/* we're done reading chunks! */
|
/* we're done reading chunks! */
|
||||||
infof(data, "chunk reading DONE\n");
|
infof(data, "chunk reading DONE\n");
|
||||||
s->keepon = FALSE;
|
s->keepon = KEEPON_DONE;
|
||||||
/* we did the full CONNECT treatment, go to COMPLETE */
|
/* we did the full CONNECT treatment, go to COMPLETE */
|
||||||
s->tunnel_state = TUNNEL_COMPLETE;
|
s->tunnel_state = TUNNEL_COMPLETE;
|
||||||
}
|
}
|
||||||
@ -474,11 +474,11 @@ static CURLcode CONNECT(struct connectdata *conn,
|
|||||||
/* without content-length or chunked encoding, we
|
/* without content-length or chunked encoding, we
|
||||||
can't keep the connection alive since the close is
|
can't keep the connection alive since the close is
|
||||||
the end signal so we bail out at once instead */
|
the end signal so we bail out at once instead */
|
||||||
s->keepon = FALSE;
|
s->keepon = KEEPON_DONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
s->keepon = FALSE;
|
s->keepon = KEEPON_DONE;
|
||||||
if(!s->cl)
|
if(!s->cl)
|
||||||
/* we did the full CONNECT treatment, go to COMPLETE */
|
/* we did the full CONNECT treatment, go to COMPLETE */
|
||||||
s->tunnel_state = TUNNEL_COMPLETE;
|
s->tunnel_state = TUNNEL_COMPLETE;
|
||||||
|
@ -802,7 +802,11 @@ struct proxy_info {
|
|||||||
/* struct for HTTP CONNECT state data */
|
/* struct for HTTP CONNECT state data */
|
||||||
struct http_connect_state {
|
struct http_connect_state {
|
||||||
struct dynbuf rcvbuf;
|
struct dynbuf rcvbuf;
|
||||||
int keepon;
|
enum keeponval {
|
||||||
|
KEEPON_DONE,
|
||||||
|
KEEPON_CONNECT,
|
||||||
|
KEEPON_IGNORE
|
||||||
|
} keepon;
|
||||||
curl_off_t cl; /* size of content to read and ignore */
|
curl_off_t cl; /* size of content to read and ignore */
|
||||||
enum {
|
enum {
|
||||||
TUNNEL_INIT, /* init/default/no tunnel state */
|
TUNNEL_INIT, /* init/default/no tunnel state */
|
||||||
|
Loading…
Reference in New Issue
Block a user