Loading CHANGES +18 −0 Original line number Diff line number Diff line Loading @@ -6,6 +6,24 @@ Changelog Daniel (12 November 2004) - *** New Behaviour Alert *** Setting CURLOPT_POSTFIELDS to NULL will no longer do a GET. Setting CURLOPT_POSTFIELDS to "" will send a zero byte POST and setting CURLOPT_POSTFIELDS to NULL and CURLOPT_POSTFIELDSIZE to zero will also make a zero byte POST. Added test case 515 to verify this. Setting CURLOPT_HTTPPOST to NULL makes a zero byte post. Added test case 516 to verify this. CURLOPT_POSTFIELDSIZE must now be set to -1 to signal "we don't know". Setting it to zero simply says this is a zero byte POST. When providing POST data with a read callback, setting the size up front is now made with CURLOPT_POSTFIELDSIZE and not with CURLOPT_INFILESIZE. Daniel (11 November 2004) - Dan Fandrich added --disable-verbose to the configure script to allow builds without verbose strings in the code, to save some 12KB space. Makes sense Loading lib/easy.c +1 −0 Original line number Diff line number Diff line Loading @@ -555,6 +555,7 @@ void curl_easy_reset(CURL *curl) data->set.fread = (curl_read_callback)fread; data->set.infilesize = -1; /* we don't know any size */ data->set.postfieldsize = -1; data->state.current_speed = -1; /* init to negative == impossible */ Loading lib/http.c +26 −6 Original line number Diff line number Diff line Loading @@ -1767,6 +1767,24 @@ CURLcode Curl_http(struct connectdata *conn) switch(httpreq) { case HTTPREQ_POST_FORM: if(!http->sendit) { /* nothing to post! */ result = add_bufferf(req_buffer, "Content-Length: 0\r\n\r\n"); if(result) return result; result = add_buffer_send(req_buffer, conn, &data->info.request_size); if(result) failf(data, "Failed sending POST request"); else /* setup variables for the upcoming transfer */ result = Curl_Transfer(conn, FIRSTSOCKET, -1, TRUE, &http->readbytecount, -1, NULL); break; } if(Curl_FormInit(&http->form, http->sendit)) { failf(data, "Internal HTTP POST error!"); return CURLE_HTTP_POST_ERROR; Loading Loading @@ -1895,7 +1913,7 @@ CURLcode Curl_http(struct connectdata *conn) /* this is the simple POST, using x-www-form-urlencoded style */ /* store the size of the postfields */ postsize = data->set.postfieldsize? postsize = (data->set.postfieldsize != -1)? data->set.postfieldsize: (data->set.postfields?(curl_off_t)strlen(data->set.postfields):0); Loading Loading @@ -1989,13 +2007,15 @@ CURLcode Curl_http(struct connectdata *conn) else { add_buffer(req_buffer, "\r\n", 2); /* end of headers! */ if(data->set.postfieldsize) { /* set the upload size to the progress meter */ Curl_pgrsSetUploadSize(data, data->set.infilesize); Curl_pgrsSetUploadSize(data, postsize?postsize:-1); /* set the pointer to mark that we will send the post body using the read callback */ http->postdata = (char *)&http->postdata; } } /* issue the request */ result = add_buffer_send(req_buffer, conn, &data->info.request_size); Loading lib/url.c +4 −5 Original line number Diff line number Diff line Loading @@ -317,6 +317,7 @@ CURLcode Curl_open(struct SessionHandle **curl) data->set.fread = (curl_read_callback)fread; data->set.infilesize = -1; /* we don't know any size */ data->set.postfieldsize = -1; data->state.current_speed = -1; /* init to negative == impossible */ Loading Loading @@ -657,10 +658,9 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option, ...) case CURLOPT_POSTFIELDS: /* * A string with POST data. Makes curl HTTP POST. * A string with POST data. Makes curl HTTP POST. Even if it is NULL. */ data->set.postfields = va_arg(param, char *); if(data->set.postfields) data->set.httpreq = HTTPREQ_POST; break; Loading @@ -685,7 +685,6 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option, ...) * Set to make us do HTTP POST */ data->set.httppost = va_arg(param, struct curl_httppost *); if(data->set.httppost) data->set.httpreq = HTTPREQ_POST_FORM; break; Loading src/main.c +12 −6 Original line number Diff line number Diff line Loading @@ -177,7 +177,6 @@ typedef enum { #define CONF_NETRC (1<<22) /* read user+password from .netrc */ #define CONF_FOLLOWLOCATION (1<<23) /* use Location: Luke! */ #define CONF_GETTEXT (1<<24) /* use ASCII/text for transfer */ #define CONF_HTTPPOST (1<<25) /* multipart/form-data HTTP POST */ #define CONF_MUTE (1<<28) /* force NOPROGRESS */ #define CONF_NETRC_OPT (1<<29) /* read user+password from either Loading Loading @@ -2850,6 +2849,7 @@ operate(struct Configurable *config, int argc, char *argv[]) helpf("error initializing curl library\n"); return CURLE_FAILED_INIT; } config->postfieldsize = -1; config->showerror=TRUE; config->conf=CONF_DEFAULT; config->use_httpget=FALSE; Loading Loading @@ -3365,11 +3365,18 @@ operate(struct Configurable *config, int argc, char *argv[]) curl_easy_setopt(curl, CURLOPT_RANGE, config->range); curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errorbuffer); curl_easy_setopt(curl, CURLOPT_TIMEOUT, config->timeout); curl_easy_setopt(curl, CURLOPT_POSTFIELDS, config->postfields); /* new in libcurl 7.2: */ switch(config->httpreq) { case HTTPREQ_SIMPLEPOST: curl_easy_setopt(curl, CURLOPT_POSTFIELDS, config->postfields); curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, config->postfieldsize); break; case HTTPREQ_POST: curl_easy_setopt(curl, CURLOPT_HTTPPOST, config->httppost); break; default: break; } curl_easy_setopt(curl, CURLOPT_REFERER, config->referer); curl_easy_setopt(curl, CURLOPT_AUTOREFERER, config->conf&CONF_AUTO_REFERER); Loading @@ -3381,7 +3388,6 @@ operate(struct Configurable *config, int argc, char *argv[]) config->use_resume?config->resume_from:0); curl_easy_setopt(curl, CURLOPT_COOKIE, config->cookie); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, config->headers); curl_easy_setopt(curl, CURLOPT_HTTPPOST, config->httppost); curl_easy_setopt(curl, CURLOPT_SSLCERT, config->cert); curl_easy_setopt(curl, CURLOPT_SSLCERTTYPE, config->cert_type); curl_easy_setopt(curl, CURLOPT_SSLKEY, config->key); Loading Loading
CHANGES +18 −0 Original line number Diff line number Diff line Loading @@ -6,6 +6,24 @@ Changelog Daniel (12 November 2004) - *** New Behaviour Alert *** Setting CURLOPT_POSTFIELDS to NULL will no longer do a GET. Setting CURLOPT_POSTFIELDS to "" will send a zero byte POST and setting CURLOPT_POSTFIELDS to NULL and CURLOPT_POSTFIELDSIZE to zero will also make a zero byte POST. Added test case 515 to verify this. Setting CURLOPT_HTTPPOST to NULL makes a zero byte post. Added test case 516 to verify this. CURLOPT_POSTFIELDSIZE must now be set to -1 to signal "we don't know". Setting it to zero simply says this is a zero byte POST. When providing POST data with a read callback, setting the size up front is now made with CURLOPT_POSTFIELDSIZE and not with CURLOPT_INFILESIZE. Daniel (11 November 2004) - Dan Fandrich added --disable-verbose to the configure script to allow builds without verbose strings in the code, to save some 12KB space. Makes sense Loading
lib/easy.c +1 −0 Original line number Diff line number Diff line Loading @@ -555,6 +555,7 @@ void curl_easy_reset(CURL *curl) data->set.fread = (curl_read_callback)fread; data->set.infilesize = -1; /* we don't know any size */ data->set.postfieldsize = -1; data->state.current_speed = -1; /* init to negative == impossible */ Loading
lib/http.c +26 −6 Original line number Diff line number Diff line Loading @@ -1767,6 +1767,24 @@ CURLcode Curl_http(struct connectdata *conn) switch(httpreq) { case HTTPREQ_POST_FORM: if(!http->sendit) { /* nothing to post! */ result = add_bufferf(req_buffer, "Content-Length: 0\r\n\r\n"); if(result) return result; result = add_buffer_send(req_buffer, conn, &data->info.request_size); if(result) failf(data, "Failed sending POST request"); else /* setup variables for the upcoming transfer */ result = Curl_Transfer(conn, FIRSTSOCKET, -1, TRUE, &http->readbytecount, -1, NULL); break; } if(Curl_FormInit(&http->form, http->sendit)) { failf(data, "Internal HTTP POST error!"); return CURLE_HTTP_POST_ERROR; Loading Loading @@ -1895,7 +1913,7 @@ CURLcode Curl_http(struct connectdata *conn) /* this is the simple POST, using x-www-form-urlencoded style */ /* store the size of the postfields */ postsize = data->set.postfieldsize? postsize = (data->set.postfieldsize != -1)? data->set.postfieldsize: (data->set.postfields?(curl_off_t)strlen(data->set.postfields):0); Loading Loading @@ -1989,13 +2007,15 @@ CURLcode Curl_http(struct connectdata *conn) else { add_buffer(req_buffer, "\r\n", 2); /* end of headers! */ if(data->set.postfieldsize) { /* set the upload size to the progress meter */ Curl_pgrsSetUploadSize(data, data->set.infilesize); Curl_pgrsSetUploadSize(data, postsize?postsize:-1); /* set the pointer to mark that we will send the post body using the read callback */ http->postdata = (char *)&http->postdata; } } /* issue the request */ result = add_buffer_send(req_buffer, conn, &data->info.request_size); Loading
lib/url.c +4 −5 Original line number Diff line number Diff line Loading @@ -317,6 +317,7 @@ CURLcode Curl_open(struct SessionHandle **curl) data->set.fread = (curl_read_callback)fread; data->set.infilesize = -1; /* we don't know any size */ data->set.postfieldsize = -1; data->state.current_speed = -1; /* init to negative == impossible */ Loading Loading @@ -657,10 +658,9 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option, ...) case CURLOPT_POSTFIELDS: /* * A string with POST data. Makes curl HTTP POST. * A string with POST data. Makes curl HTTP POST. Even if it is NULL. */ data->set.postfields = va_arg(param, char *); if(data->set.postfields) data->set.httpreq = HTTPREQ_POST; break; Loading @@ -685,7 +685,6 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option, ...) * Set to make us do HTTP POST */ data->set.httppost = va_arg(param, struct curl_httppost *); if(data->set.httppost) data->set.httpreq = HTTPREQ_POST_FORM; break; Loading
src/main.c +12 −6 Original line number Diff line number Diff line Loading @@ -177,7 +177,6 @@ typedef enum { #define CONF_NETRC (1<<22) /* read user+password from .netrc */ #define CONF_FOLLOWLOCATION (1<<23) /* use Location: Luke! */ #define CONF_GETTEXT (1<<24) /* use ASCII/text for transfer */ #define CONF_HTTPPOST (1<<25) /* multipart/form-data HTTP POST */ #define CONF_MUTE (1<<28) /* force NOPROGRESS */ #define CONF_NETRC_OPT (1<<29) /* read user+password from either Loading Loading @@ -2850,6 +2849,7 @@ operate(struct Configurable *config, int argc, char *argv[]) helpf("error initializing curl library\n"); return CURLE_FAILED_INIT; } config->postfieldsize = -1; config->showerror=TRUE; config->conf=CONF_DEFAULT; config->use_httpget=FALSE; Loading Loading @@ -3365,11 +3365,18 @@ operate(struct Configurable *config, int argc, char *argv[]) curl_easy_setopt(curl, CURLOPT_RANGE, config->range); curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errorbuffer); curl_easy_setopt(curl, CURLOPT_TIMEOUT, config->timeout); curl_easy_setopt(curl, CURLOPT_POSTFIELDS, config->postfields); /* new in libcurl 7.2: */ switch(config->httpreq) { case HTTPREQ_SIMPLEPOST: curl_easy_setopt(curl, CURLOPT_POSTFIELDS, config->postfields); curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, config->postfieldsize); break; case HTTPREQ_POST: curl_easy_setopt(curl, CURLOPT_HTTPPOST, config->httppost); break; default: break; } curl_easy_setopt(curl, CURLOPT_REFERER, config->referer); curl_easy_setopt(curl, CURLOPT_AUTOREFERER, config->conf&CONF_AUTO_REFERER); Loading @@ -3381,7 +3388,6 @@ operate(struct Configurable *config, int argc, char *argv[]) config->use_resume?config->resume_from:0); curl_easy_setopt(curl, CURLOPT_COOKIE, config->cookie); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, config->headers); curl_easy_setopt(curl, CURLOPT_HTTPPOST, config->httppost); curl_easy_setopt(curl, CURLOPT_SSLCERT, config->cert); curl_easy_setopt(curl, CURLOPT_SSLCERTTYPE, config->cert_type); curl_easy_setopt(curl, CURLOPT_SSLKEY, config->key); Loading