summaryrefslogtreecommitdiffstats
path: root/lib/url.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/url.c')
-rw-r--r--lib/url.c80
1 files changed, 45 insertions, 35 deletions
diff --git a/lib/url.c b/lib/url.c
index e3e7f45..4f5673e 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -414,7 +414,7 @@ CURLcode Curl_close(struct Curl_easy **datap)
Curl_hsts_cleanup(&data->hsts);
curl_slist_free_all(data->set.hstslist); /* clean up list */
#endif
-#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_CRYPTO_AUTH)
+#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_DIGEST_AUTH)
Curl_http_auth_cleanup_digest(data);
#endif
Curl_safefree(data->info.contenttype);
@@ -457,6 +457,11 @@ CURLcode Curl_close(struct Curl_easy **datap)
}
#endif
+ Curl_mime_cleanpart(data->state.formp);
+#ifndef CURL_DISABLE_HTTP
+ Curl_safefree(data->state.formp);
+#endif
+
/* destruct wildcard structures if it is needed */
Curl_wildcard_dtor(&data->wildcard);
Curl_freeset(data);
@@ -490,7 +495,7 @@ CURLcode Curl_init_userdefined(struct Curl_easy *data)
set->filesize = -1; /* we don't know the size */
set->postfieldsize = -1; /* unknown size */
- set->maxredirs = -1; /* allow any amount by default */
+ set->maxredirs = 30; /* sensible default */
set->method = HTTPREQ_GET; /* Default HTTP request */
#ifndef CURL_DISABLE_RTSP
@@ -948,7 +953,7 @@ static bool extract_if_dead(struct connectdata *conn,
* that we expect - in general - no waiting input data. Input
* waiting might be a TLS Notify Close, for example. We reject
* that.
- * For protocols where data from other other end may arrive at
+ * For protocols where data from other end may arrive at
* any time (HTTP/2 PING for example), the protocol handler needs
* to install its own `connection_check` callback.
*/
@@ -1073,6 +1078,9 @@ ConnectionExists(struct Curl_easy *data,
bool wantProxyNTLMhttp = FALSE;
#endif
#endif
+ /* plain HTTP with upgrade */
+ bool h2upgrade = (data->state.httpwant == CURL_HTTP_VERSION_2_0) &&
+ (needle->handler->protocol & CURLPROTO_HTTP);
*force_reuse = FALSE;
*waitpipe = FALSE;
@@ -1095,7 +1103,7 @@ ConnectionExists(struct Curl_easy *data,
infof(data, "Server doesn't support multiplex yet, wait");
*waitpipe = TRUE;
CONNCACHE_UNLOCK(data);
- return FALSE; /* no re-use */
+ return FALSE; /* no reuse */
}
infof(data, "Server doesn't support multiplex (yet)");
@@ -1135,7 +1143,7 @@ ConnectionExists(struct Curl_easy *data,
}
if(data->set.ipver != CURL_IPRESOLVE_WHATEVER
- && data->set.ipver != check->ip_version) {
+ && data->set.ipver != check->ip_version) {
/* skip because the connection is not via the requested IP version */
continue;
}
@@ -1150,16 +1158,11 @@ ConnectionExists(struct Curl_easy *data,
continue;
}
- if(Curl_resolver_asynch()) {
- /* primary_ip[0] is NUL only if the resolving of the name hasn't
- completed yet and until then we don't re-use this connection */
- if(!check->primary_ip[0]) {
- infof(data, "Connection #%" CURL_FORMAT_CURL_OFF_T " is still "
- "name resolving, can't reuse",
- check->connection_id);
- continue;
- }
- }
+ if(Curl_resolver_asynch() &&
+ /* primary_ip[0] is NUL only if the resolving of the name hasn't
+ completed yet and until then we don't reuse this connection */
+ !check->primary_ip[0])
+ continue;
}
if(!Curl_conn_is_connected(check, FIRSTSOCKET)) {
@@ -1238,6 +1241,17 @@ ConnectionExists(struct Curl_easy *data,
}
#endif
+ if(h2upgrade && !check->httpversion && canmultiplex) {
+ if(data->set.pipewait) {
+ infof(data, "Server upgrade doesn't support multiplex yet, wait");
+ *waitpipe = TRUE;
+ CONNCACHE_UNLOCK(data);
+ return FALSE; /* no reuse */
+ }
+ infof(data, "Server upgrade cannot be used");
+ continue; /* can't be used atm */
+ }
+
if(!canmultiplex && CONN_INUSE(check))
/* this request can't be multiplexed but the checked connection is
already in use so we skip it */
@@ -1254,14 +1268,14 @@ ConnectionExists(struct Curl_easy *data,
if(needle->localdev || needle->localport) {
/* If we are bound to a specific local end (IP+port), we must not
- re-use a random other one, although if we didn't ask for a
+ reuse a random other one, although if we didn't ask for a
particular one we can reuse one that was bound.
This comparison is a bit rough and too strict. Since the input
parameters can be specified in numerous ways and still end up the
same it would take a lot of processing to make it really accurate.
- Instead, this matching will assume that re-uses of bound connections
- will most likely also re-use the exact same binding parameters and
+ Instead, this matching will assume that reuses of bound connections
+ will most likely also reuse the exact same binding parameters and
missing out a few edge cases shouldn't hurt anyone very much.
*/
if((check->localport != needle->localport) ||
@@ -1294,7 +1308,7 @@ ConnectionExists(struct Curl_easy *data,
(((check->httpversion >= 20) &&
(data->state.httpwant < CURL_HTTP_VERSION_2_0))
|| ((check->httpversion >= 30) &&
- (data->state.httpwant < CURL_HTTP_VERSION_3))))
+ (data->state.httpwant < CURL_HTTP_VERSION_3))))
continue;
#ifdef USE_SSH
else if(get_protocol_family(needle->handler) & PROTO_FAMILY_SSH) {
@@ -1485,13 +1499,7 @@ void Curl_verboseconnect(struct Curl_easy *data,
{
if(data->set.verbose)
infof(data, "Connected to %s (%s) port %u",
-#ifndef CURL_DISABLE_PROXY
- conn->bits.socksproxy ? conn->socks_proxy.host.dispname :
- conn->bits.httpproxy ? conn->http_proxy.host.dispname :
-#endif
- conn->bits.conn_to_host ? conn->conn_to_host.dispname :
- conn->host.dispname,
- conn->primary_ip, conn->port);
+ CURL_CONN_HOST_DISPNAME(conn), conn->primary_ip, conn->port);
}
#endif
@@ -1587,8 +1595,10 @@ static struct connectdata *allocate_conn(struct Curl_easy *data)
if(!conn->localdev)
goto error;
}
+#ifndef CURL_DISABLE_BINDLOCAL
conn->localportrange = data->set.localportrange;
conn->localport = data->set.localport;
+#endif
/* the close socket stuff needs to be copied to the connection struct as
it may live on without (this specific) Curl_easy */
@@ -2120,7 +2130,7 @@ static char *detect_proxy(struct Curl_easy *data,
/*
* If this is supposed to use a proxy, we need to figure out the proxy
- * host name, so that we can re-use an existing connection
+ * host name, so that we can reuse an existing connection
* that may exist registered to the same proxy host.
*/
static CURLcode parse_proxy(struct Curl_easy *data,
@@ -2441,7 +2451,7 @@ static CURLcode create_conn_helper_init_proxy(struct Curl_easy *data,
/***********************************************************************
* If this is supposed to use a proxy, we need to figure out the proxy host
- * name, proxy type and port number, so that we can re-use an existing
+ * name, proxy type and port number, so that we can reuse an existing
* connection that may exist registered to the same proxy host.
***********************************************************************/
if(proxy || socksproxy) {
@@ -3259,7 +3269,7 @@ static CURLcode resolve_server(struct Curl_easy *data,
/* Resolve the name of the server or proxy */
if(conn->bits.reuse) {
/* We're reusing the connection - no need to resolve anything, and
- idnconvert_hostname() was called already in create_conn() for the re-use
+ idnconvert_hostname() was called already in create_conn() for the reuse
case. */
*async = FALSE;
return CURLE_OK;
@@ -3278,7 +3288,7 @@ static void reuse_conn(struct Curl_easy *data,
struct connectdata *existing)
{
/* get the user+password information from the temp struct since it may
- * be new for this request even when we re-use an existing connection */
+ * be new for this request even when we reuse an existing connection */
if(temp->user) {
/* use the new user name and password though */
Curl_safefree(existing->user);
@@ -3338,14 +3348,14 @@ static void reuse_conn(struct Curl_easy *data,
existing->hostname_resolve = temp->hostname_resolve;
temp->hostname_resolve = NULL;
- /* re-use init */
- existing->bits.reuse = TRUE; /* yes, we're re-using here */
+ /* reuse init */
+ existing->bits.reuse = TRUE; /* yes, we're reusing here */
conn_free(data, temp);
}
/**
- * create_conn() sets up a new connectdata struct, or re-uses an already
+ * create_conn() sets up a new connectdata struct, or reuses an already
* existing one, and resolves host name.
*
* if this function returns CURLE_OK and *async is set to TRUE, the resolve
@@ -3657,7 +3667,7 @@ static CURLcode create_conn(struct Curl_easy *data,
/*************************************************************
* Check the current list of connections to see if we can
- * re-use an already existing one or if we have to create a
+ * reuse an already existing one or if we have to create a
* new one.
*************************************************************/
@@ -3665,7 +3675,7 @@ static CURLcode create_conn(struct Curl_easy *data,
DEBUGASSERT(conn->passwd);
/* reuse_fresh is TRUE if we are told to use a new connection by force, but
- we only acknowledge this option if this is not a re-used connection
+ we only acknowledge this option if this is not a reused connection
already (which happens due to follow-location or during an HTTP
authentication phase). CONNECT_ONLY transfers also refuse reuse. */
if((data->set.reuse_fresh && !data->state.followlocation) ||