data->change.referer_alloc = FALSE;
}
data->change.referer = NULL;
+ if(data->change.url_alloc) {
+ Curl_safefree(data->change.url);
+ data->change.url_alloc = FALSE;
+ }
+ data->change.url = NULL;
}
static CURLcode setstropt(char **charp, char *s)
set->convtonetwork = ZERO_NULL;
set->convfromutf8 = ZERO_NULL;
- set->infilesize = -1; /* we don't know any size */
+ set->filesize = -1; /* we don't know the size */
set->postfieldsize = -1; /* unknown size */
set->maxredirs = -1; /* allow any amount by default */
if(argptr == NULL)
break;
- Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE);
-
if(Curl_raw_equal(argptr, "ALL")) {
/* clear all cookies */
+ Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE);
Curl_cookie_clearall(data->cookies);
+ Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE);
}
else if(Curl_raw_equal(argptr, "SESS")) {
/* clear session cookies */
+ Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE);
Curl_cookie_clearsess(data->cookies);
+ Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE);
}
else if(Curl_raw_equal(argptr, "FLUSH")) {
- /* flush cookies to file */
+ /* flush cookies to file, takes care of the locking */
Curl_flush_cookies(data, 0);
}
else {
result = CURLE_OUT_OF_MEMORY;
}
else {
+ Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE);
if(checkprefix("Set-Cookie:", argptr))
/* HTTP Header format line */
/* Netscape format line */
Curl_cookie_add(data, data->cookies, FALSE, argptr, NULL, NULL);
+ Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE);
free(argptr);
}
}
- Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE);
break;
#endif /* CURL_DISABLE_COOKIES */
break;
#endif
- case CURLOPT_WRITEHEADER:
+ case CURLOPT_HEADERDATA:
/*
* Custom pointer to pass the header write callback function
*/
*/
data->set.errorbuffer = va_arg(param, char *);
break;
- case CURLOPT_FILE:
+ case CURLOPT_WRITEDATA:
/*
* FILE pointer to write to. Or possibly
* used as argument to the write callback.
* If known, this should inform curl about the file size of the
* to-be-uploaded file.
*/
- data->set.infilesize = va_arg(param, long);
+ data->set.filesize = va_arg(param, long);
break;
case CURLOPT_INFILESIZE_LARGE:
/*
* If known, this should inform curl about the file size of the
* to-be-uploaded file.
*/
- data->set.infilesize = va_arg(param, curl_off_t);
+ data->set.filesize = va_arg(param, curl_off_t);
break;
case CURLOPT_LOW_SPEED_LIMIT:
/*
static CURLcode ConnectionStore(struct SessionHandle *data,
struct connectdata *conn)
{
- static int connection_id_counter = 0;
-
- CURLcode result;
-
- /* Assign a number to the connection for easier tracking in the log
- output */
- conn->connection_id = connection_id_counter++;
-
- result = Curl_conncache_add_conn(data->state.conn_cache, conn);
- if(result != CURLE_OK)
- conn->connection_id = -1;
-
- return result;
+ return Curl_conncache_add_conn(data->state.conn_cache, conn);
}
/* after a TCP connection to the proxy has been verified, this function does
static void fix_hostname(struct SessionHandle *data,
struct connectdata *conn, struct hostname *host)
{
+ size_t len;
+
#ifndef USE_LIBIDN
(void)data;
(void)conn;
/* set the name we use to display the host name */
host->dispname = host->name;
+
+ len = strlen(host->name);
+ if(host->name[len-1] == '.')
+ /* strip off a single trailing dot if present, primarily for SNI but
+ there's no use for it */
+ host->name[len-1]=0;
+
if(!is_ASCII_name(host->name)) {
#ifdef USE_LIBIDN
/*************************************************************
/* Default protocol-independent behavior doesn't support persistent
connections, so we set this to force-close. Protocols that support
this need to set this to FALSE in their "curl_do" functions. */
- conn->bits.close = TRUE;
+ connclose(conn, "Default to force-close");
/* Store creation time to help future close decision making */
conn->created = Curl_tvnow();
}
else {
/* Zone identifier is not numeric */
-#if defined(HAVE_NET_IF_H) && defined(IFNAMSIZ)
+#if defined(HAVE_NET_IF_H) && defined(IFNAMSIZ) && defined(HAVE_IF_NAMETOINDEX)
char ifname[IFNAMSIZ + 2];
char *square_bracket;
unsigned int scopeidx = 0;
{
const struct Curl_handler * p;
CURLcode result;
+ struct SessionHandle *data = conn->data;
/* in some case in the multi state-machine, we go back to the CONNECT state
and then a second (or third or...) call to this function will be made
without doing a DISCONNECT or DONE in between (since the connection is
yet in place) and therefore this function needs to first make sure
there's no lingering previous data allocated. */
- Curl_free_request_state(conn->data);
+ Curl_free_request_state(data);
- memset(&conn->data->req, 0, sizeof(struct SingleRequest));
- conn->data->req.maxdownload = -1;
+ memset(&data->req, 0, sizeof(struct SingleRequest));
+ data->req.maxdownload = -1;
conn->socktype = SOCK_STREAM; /* most of them are TCP streams */
void Curl_free_request_state(struct SessionHandle *data)
{
Curl_safefree(data->req.protop);
+ Curl_safefree(data->req.newurl);
}
char *proxy = NULL;
bool prot_missing = FALSE;
bool no_connections_available = FALSE;
- bool force_reuse;
+ bool force_reuse = FALSE;
size_t max_host_connections = Curl_multi_max_host_connections(data->multi);
size_t max_total_connections = Curl_multi_max_total_connections(data->multi);
if(conn->handler->done)
result = conn->handler->done(conn, status, premature);
else
- result = CURLE_OK;
+ result = status;
- if(Curl_pgrsDone(conn) && !result)
+ if(!result && Curl_pgrsDone(conn))
result = CURLE_ABORTED_BY_CALLBACK;
/* if the transfer was completed in a paused state there can be buffered