Skip to content

Commit

Permalink
http-proxy: do the HTTP CONNECT process entirely non-blocking
Browse files Browse the repository at this point in the history
Mentioned as a problem since 2007 (8f87c15) and of course it
existed even before that.
  • Loading branch information
bagder committed Jun 7, 2017
1 parent 68c6dcb commit 32eddae
Show file tree
Hide file tree
Showing 9 changed files with 177 additions and 133 deletions.
3 changes: 1 addition & 2 deletions docs/libcurl/libcurl-multi.3
Expand Up @@ -5,7 +5,7 @@
.\" * | (__| |_| | _ <| |___
.\" * \___|\___/|_| \_\_____|
.\" *
.\" * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
.\" * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
.\" *
.\" * This software is licensed as described in the file COPYING, which
.\" * you should have received as part of this distribution. The terms
Expand Down Expand Up @@ -173,7 +173,6 @@ the future, you should be aware of the following current restrictions:

.nf
- Name resolves unless the c-ares or threaded-resolver backends are used
- HTTP proxy CONNECT operations
- SOCKS proxy handshakes
- file:// transfers
- TELNET transfers
Expand Down
5 changes: 2 additions & 3 deletions lib/ftp.c
Expand Up @@ -272,7 +272,6 @@ static void close_secondarysocket(struct connectdata *conn)
conn->sock[SECONDARYSOCKET] = CURL_SOCKET_BAD;
}
conn->bits.tcpconnect[SECONDARYSOCKET] = FALSE;
conn->tunnel_state[SECONDARYSOCKET] = TUNNEL_INIT;
}

/*
Expand Down Expand Up @@ -3585,7 +3584,7 @@ static CURLcode ftp_do_more(struct connectdata *conn, int *completep)

/* if the second connection isn't done yet, wait for it */
if(!conn->bits.tcpconnect[SECONDARYSOCKET]) {
if(conn->tunnel_state[SECONDARYSOCKET] == TUNNEL_CONNECT) {
if(Curl_connect_ongoing(conn)) {
/* As we're in TUNNEL_CONNECT state now, we know the proxy name and port
aren't used so we blank their arguments. TODO: make this nicer */
result = Curl_proxyCONNECT(conn, SECONDARYSOCKET, NULL, 0);
Expand Down Expand Up @@ -3617,7 +3616,7 @@ static CURLcode ftp_do_more(struct connectdata *conn, int *completep)
return result;

if(conn->bits.tunnel_proxy && conn->bits.httpproxy &&
conn->tunnel_state[SECONDARYSOCKET] != TUNNEL_COMPLETE)
Curl_connect_ongoing(conn))
return result;


Expand Down
2 changes: 1 addition & 1 deletion lib/http.c
Expand Up @@ -1369,7 +1369,7 @@ CURLcode Curl_http_connect(struct connectdata *conn, bool *done)
if(CONNECT_FIRSTSOCKET_PROXY_SSL())
return CURLE_OK; /* wait for HTTPS proxy SSL initialization to complete */

if(conn->tunnel_state[FIRSTSOCKET] == TUNNEL_CONNECT)
if(!Curl_connect_complete(conn))
/* nothing else to do except wait right now - we're not done here. */
return CURLE_OK;

Expand Down

0 comments on commit 32eddae

Please sign in to comment.