aboutsummaryrefslogtreecommitdiff
path: root/lib/http.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2013-08-04 19:34:16 +0200
committerDaniel Stenberg <daniel@haxx.se>2013-08-12 13:17:57 +0200
commit4ad8e142da463ab208d5b5565e53291c8e5ef038 (patch)
treed50e9d8c79ee1a8b1b1a71894b033808a68eab59 /lib/http.c
parente3ee73b70ceaf2663fc2d26a4102e131a7c9618d (diff)
urldata: clean up the use of the protocol specific structs
1 - always allocate the struct in protocol->setup_connection. Some protocol handlers had to get this function added. 2 - always free at the end of a request. This is also an attempt to keep less memory in the handle after it is completed.
Diffstat (limited to 'lib/http.c')
-rw-r--r--lib/http.c35
1 files changed, 19 insertions, 16 deletions
diff --git a/lib/http.c b/lib/http.c
index f4b7a48e7..8913c5a6d 100644
--- a/lib/http.c
+++ b/lib/http.c
@@ -105,7 +105,7 @@ static int https_getsock(struct connectdata *conn,
*/
const struct Curl_handler Curl_handler_http = {
"HTTP", /* scheme */
- ZERO_NULL, /* setup_connection */
+ Curl_http_setup_conn, /* setup_connection */
Curl_http, /* do_it */
Curl_http_done, /* done */
ZERO_NULL, /* do_more */
@@ -129,7 +129,7 @@ const struct Curl_handler Curl_handler_http = {
*/
const struct Curl_handler Curl_handler_https = {
"HTTPS", /* scheme */
- ZERO_NULL, /* setup_connection */
+ Curl_http_setup_conn, /* setup_connection */
Curl_http, /* do_it */
Curl_http_done, /* done */
ZERO_NULL, /* do_more */
@@ -149,6 +149,21 @@ const struct Curl_handler Curl_handler_https = {
#endif
+CURLcode Curl_http_setup_conn(struct connectdata *conn)
+{
+ /* allocate the HTTP-specific struct for the SessionHandle, only to survive
+ during this request */
+ struct HTTP *http;
+
+ DEBUGASSERT(conn->data->state.proto.http == NULL);
+
+ conn->data->state.proto.http = http = calloc(1, sizeof(struct HTTP));
+ if(!http)
+ return CURLE_OUT_OF_MEMORY;
+
+ return CURLE_OK;
+}
+
/*
* checkheaders() checks the linked list of custom HTTP headers for a
* particular header (prefix).
@@ -1442,6 +1457,7 @@ CURLcode Curl_http_done(struct connectdata *conn,
if(!premature && /* this check is pointless when DONE is called before the
entire operation is complete */
!conn->bits.retry &&
+ !data->set.connect_only &&
((http->readbytecount +
data->req.headerbytecount -
data->req.deductheadercount)) <= 0) {
@@ -1655,20 +1671,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
the rest of the request in the PERFORM phase. */
*done = TRUE;
- /* If there already is a protocol-specific struct allocated for this
- sessionhandle, deal with it */
- Curl_reset_reqproto(conn);
-
- if(!data->state.proto.http) {
- /* Only allocate this struct if we don't already have it! */
-
- http = calloc(1, sizeof(struct HTTP));
- if(!http)
- return CURLE_OUT_OF_MEMORY;
- data->state.proto.http = http;
- }
- else
- http = data->state.proto.http;
+ http = data->state.proto.http;
if(!data->state.this_is_a_follow) {
/* this is not a followed location, get the original host name */