[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnurl] 335/411: http_proxy: use enum with state names for 'keepon'
From: |
gnunet |
Subject: |
[gnurl] 335/411: http_proxy: use enum with state names for 'keepon' |
Date: |
Wed, 13 Jan 2021 01:22:30 +0100 |
This is an automated email from the git hooks/post-receive script.
nikita pushed a commit to branch master
in repository gnurl.
commit c49d205ae021d9e02e0466905d4aac49665b2b19
Author: Daniel Stenberg <daniel@haxx.se>
AuthorDate: Mon Nov 9 23:48:25 2020 +0100
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
---
lib/http_proxy.c | 20 ++++++++++----------
lib/urldata.h | 6 +++++-
2 files changed, 15 insertions(+), 11 deletions(-)
diff --git a/lib/http_proxy.c b/lib/http_proxy.c
index 6f5a7d6ab..61c4b9931 100644
--- a/lib/http_proxy.c
+++ b/lib/http_proxy.c
@@ -167,7 +167,7 @@ static CURLcode connect_init(struct connectdata *conn, bool
reinit)
Curl_dyn_reset(&s->rcvbuf);
}
s->tunnel_state = TUNNEL_INIT;
- s->keepon = TRUE;
+ s->keepon = KEEPON_CONNECT;
s->cl = 0;
s->close_connection = FALSE;
return CURLE_OK;
@@ -339,7 +339,7 @@ static CURLcode CONNECT(struct connectdata *conn,
return CURLE_ABORTED_BY_CALLBACK;
if(result) {
- s->keepon = FALSE;
+ s->keepon = KEEPON_DONE;
break;
}
else if(gotbytes <= 0) {
@@ -353,11 +353,11 @@ static CURLcode CONNECT(struct connectdata *conn,
error = SELECT_ERROR;
failf(data, "Proxy CONNECT aborted");
}
- s->keepon = FALSE;
+ s->keepon = KEEPON_DONE;
break;
}
- if(s->keepon > TRUE) {
+ if(s->keepon == KEEPON_IGNORE) {
/* This means we are currently ignoring a response-body */
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! */
s->cl--;
if(s->cl <= 0) {
- s->keepon = FALSE;
+ s->keepon = KEEPON_DONE;
s->tunnel_state = TUNNEL_COMPLETE;
break;
}
@@ -383,7 +383,7 @@ static CURLcode CONNECT(struct connectdata *conn,
if(r == CHUNKE_STOP) {
/* we're done reading chunks! */
infof(data, "chunk reading DONE\n");
- s->keepon = FALSE;
+ s->keepon = KEEPON_DONE;
/* we did the full CONNECT treatment, go 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
when we have no auth problem, we must ignore the
whole response-body */
- s->keepon = 2;
+ s->keepon = KEEPON_IGNORE;
if(s->cl) {
infof(data, "Ignore %" CURL_FORMAT_CURL_OFF_T
@@ -465,7 +465,7 @@ static CURLcode CONNECT(struct connectdata *conn,
if(r == CHUNKE_STOP) {
/* we're done reading chunks! */
infof(data, "chunk reading DONE\n");
- s->keepon = FALSE;
+ s->keepon = KEEPON_DONE;
/* we did the full CONNECT treatment, go to COMPLETE */
s->tunnel_state = TUNNEL_COMPLETE;
}
@@ -474,11 +474,11 @@ static CURLcode CONNECT(struct connectdata *conn,
/* without content-length or chunked encoding, we
can't keep the connection alive since the close is
the end signal so we bail out at once instead */
- s->keepon = FALSE;
+ s->keepon = KEEPON_DONE;
}
}
else
- s->keepon = FALSE;
+ s->keepon = KEEPON_DONE;
if(!s->cl)
/* we did the full CONNECT treatment, go to COMPLETE */
s->tunnel_state = TUNNEL_COMPLETE;
diff --git a/lib/urldata.h b/lib/urldata.h
index 4a2a97afc..a3c2b3cf3 100644
--- a/lib/urldata.h
+++ b/lib/urldata.h
@@ -802,7 +802,11 @@ struct proxy_info {
/* struct for HTTP CONNECT state data */
struct http_connect_state {
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 */
enum {
TUNNEL_INIT, /* init/default/no tunnel state */
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [gnurl] 320/411: url: make sure an HSTS upgrade updates URL and scheme correctly, (continued)
- [gnurl] 320/411: url: make sure an HSTS upgrade updates URL and scheme correctly, gnunet, 2021/01/12
- [gnurl] 369/411: examples: update .gitignore, gnunet, 2021/01/12
- [gnurl] 328/411: examples/httpput: remove use of CURLOPT_PUT, gnunet, 2021/01/12
- [gnurl] 325/411: configure: pass -pthread to Libs.private for pkg-config, gnunet, 2021/01/12
- [gnurl] 301/411: curlver: bumped to 7.74.0, gnunet, 2021/01/12
- [gnurl] 332/411: mqttd: fclose test file when done, gnunet, 2021/01/12
- [gnurl] 309/411: KNOWN_BUGS: SMB tests fail with Python 2, gnunet, 2021/01/12
- [gnurl] 324/411: altsvc: minimize variable scope and avoid "DEAD_STORE", gnunet, 2021/01/12
- [gnurl] 282/411: libssh2: fix transport over HTTPS proxy, gnunet, 2021/01/12
- [gnurl] 363/411: KNOWN_BUGS: curl with wolfSSL lacks support for renegotiation, gnunet, 2021/01/12
- [gnurl] 335/411: http_proxy: use enum with state names for 'keepon',
gnunet <=
- [gnurl] 298/411: CI/tests: enable test target on TravisCI for CMake builds, gnunet, 2021/01/12
- [gnurl] 358/411: CI/cirrus: simplify logic for disabled tests, gnunet, 2021/01/12
- [gnurl] 370/411: docs/INTERNALS: remove reference to Curl_sendf(), gnunet, 2021/01/12
- [gnurl] 336/411: cmake: don't pass -fvisibility=hidden to clang-cl on Windows, gnunet, 2021/01/12
- [gnurl] 338/411: httpput-postfields.c: new example doing PUT with POSTFIELDS, gnunet, 2021/01/12
- [gnurl] 276/411: CI/github: work-around for brew breakage on macOS, gnunet, 2021/01/12
- [gnurl] 303/411: RELEASE-NOTES: synced, gnunet, 2021/01/12
- [gnurl] 293/411: gnutls: fix memory leaks (certfields memory wasn't released), gnunet, 2021/01/12
- [gnurl] 316/411: examples: fix comment syntax, gnunet, 2021/01/12
- [gnurl] 283/411: CMake: make BUILD_TESTING dependent option, gnunet, 2021/01/12