aboutsummaryrefslogtreecommitdiff
path: root/lib/http.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2015-10-05 20:39:10 +0200
committerDaniel Stenberg <daniel@haxx.se>2015-10-15 23:32:19 +0200
commitc6aedf680f6923ffbe4dd4fd4e68e7dadcd5fb19 (patch)
tree4f681e394e33c436ea94fd40db2ec126afdc0977 /lib/http.c
parent854976ad7b049e3a758d3d0ec33d5c998e36e5af (diff)
fread_func: move callback pointer from set to state struct
... and assign it from the set.fread_func_set pointer in the Curl_init_CONNECT function. This A) avoids that we have code that assigns fields in the 'set' struct (which we always knew was bad) and more importantly B) it makes it impossibly to accidentally leave the wrong value for when the handle is re-used etc. Introducing a state-init functionality in multi.c, so that we can set a specific function to get called when we enter a state. The Curl_init_CONNECT is thus called when switching to the CONNECT state. Bug: https://github.com/bagder/curl/issues/346 Closes #346
Diffstat (limited to 'lib/http.c')
-rw-r--r--lib/http.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/lib/http.c b/lib/http.c
index d7b56c30b..59f6436fe 100644
--- a/lib/http.c
+++ b/lib/http.c
@@ -1001,8 +1001,8 @@ static size_t readmoredata(char *buffer,
/* move backup data into focus and continue on that */
http->postdata = http->backup.postdata;
http->postsize = http->backup.postsize;
- conn->data->set.fread_func = http->backup.fread_func;
- conn->data->set.in = http->backup.fread_in;
+ conn->data->state.fread_func = http->backup.fread_func;
+ conn->data->state.in = http->backup.fread_in;
http->sending++; /* move one step up */
@@ -1157,14 +1157,14 @@ CURLcode Curl_add_buffer_send(Curl_send_buffer *in,
ptr = in->buffer + amount;
/* backup the currently set pointers */
- http->backup.fread_func = conn->data->set.fread_func;
- http->backup.fread_in = conn->data->set.in;
+ http->backup.fread_func = conn->data->state.fread_func;
+ http->backup.fread_in = conn->data->state.in;
http->backup.postdata = http->postdata;
http->backup.postsize = http->postsize;
/* set the new pointers for the request-sending */
- conn->data->set.fread_func = (curl_read_callback)readmoredata;
- conn->data->set.in = (void *)conn;
+ conn->data->state.fread_func = (curl_read_callback)readmoredata;
+ conn->data->state.in = (void *)conn;
http->postdata = ptr;
http->postsize = (curl_off_t)size;
@@ -2162,8 +2162,8 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
BUFSIZE : curlx_sotouz(data->state.resume_from - passed);
size_t actuallyread =
- data->set.fread_func(data->state.buffer, 1, readthisamountnow,
- data->set.in);
+ data->state.fread_func(data->state.buffer, 1, readthisamountnow,
+ data->state.in);
passed += actuallyread;
if((actuallyread == 0) || (actuallyread > readthisamountnow)) {
@@ -2437,11 +2437,11 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
on. The data->set.fread_func pointer itself will be changed for the
multipart case to the function that returns a multipart formatted
stream. */
- http->form.fread_func = data->set.fread_func;
+ http->form.fread_func = data->state.fread_func;
/* Set the read function to read from the generated form data */
- data->set.fread_func = (curl_read_callback)Curl_FormReader;
- data->set.in = &http->form;
+ data->state.fread_func = (curl_read_callback)Curl_FormReader;
+ data->state.in = &http->form;
http->sending = HTTPSEND_BODY;
@@ -2659,8 +2659,8 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
http->sending = HTTPSEND_BODY;
- data->set.fread_func = (curl_read_callback)readmoredata;
- data->set.in = (void *)conn;
+ data->state.fread_func = (curl_read_callback)readmoredata;
+ data->state.in = (void *)conn;
/* set the upload size to the progress meter */
Curl_pgrsSetUploadSize(data, http->postsize);