This commit is contained in:
Daniel Stenberg 2001-08-03 11:52:53 +00:00
Родитель 9b69f6faab
Коммит 8987244758
4 изменённых файлов: 31 добавлений и 31 удалений

Просмотреть файл

@ -361,7 +361,7 @@ CURLcode Curl_http_done(struct connectdata *conn)
data=conn->data; data=conn->data;
http=conn->proto.http; http=conn->proto.http;
if(data->bits.http_formpost) { if(HTTPREQ_POST_FORM == data->httpreq) {
*bytecount = http->readbytecount + http->writebytecount; *bytecount = http->readbytecount + http->writebytecount;
Curl_FormFree(http->sendit); /* Now free that whole lot */ Curl_FormFree(http->sendit); /* Now free that whole lot */
@ -369,7 +369,7 @@ CURLcode Curl_http_done(struct connectdata *conn)
data->fread = http->storefread; /* restore */ data->fread = http->storefread; /* restore */
data->in = http->in; /* restore */ data->in = http->in; /* restore */
} }
else if(data->bits.http_put) { else if(HTTPREQ_PUT == data->httpreq) {
*bytecount = http->readbytecount + http->writebytecount; *bytecount = http->readbytecount + http->writebytecount;
} }
@ -405,7 +405,7 @@ CURLcode Curl_http(struct connectdata *conn)
if ( (conn->protocol&(PROT_HTTP|PROT_FTP)) && if ( (conn->protocol&(PROT_HTTP|PROT_FTP)) &&
data->bits.upload) { data->bits.upload) {
data->bits.http_put=1; data->httpreq = HTTPREQ_PUT;
} }
/* The User-Agent string has been built in url.c already, because it might /* The User-Agent string has been built in url.c already, because it might
@ -457,7 +457,7 @@ CURLcode Curl_http(struct connectdata *conn)
/* The path sent to the proxy is in fact the entire URL */ /* The path sent to the proxy is in fact the entire URL */
ppath = data->url; ppath = data->url;
} }
if(data->bits.http_formpost) { if(HTTPREQ_POST_FORM == data->httpreq) {
/* we must build the whole darned post sequence first, so that we have /* we must build the whole darned post sequence first, so that we have
a size of the whole shebang before we start to send it */ a size of the whole shebang before we start to send it */
http->sendit = Curl_getFormData(data->httppost, &http->postsize); http->sendit = Curl_getFormData(data->httppost, &http->postsize);
@ -488,9 +488,9 @@ CURLcode Curl_http(struct connectdata *conn)
if(!checkheaders(data, "Accept:")) if(!checkheaders(data, "Accept:"))
http->p_accept = "Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*\r\n"; http->p_accept = "Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*\r\n";
if((data->bits.http_post || if(( (HTTPREQ_POST == data->httpreq) ||
data->bits.http_formpost || (HTTPREQ_POST_FORM == data->httpreq) ||
data->bits.http_put) && (HTTPREQ_PUT == data->httpreq) ) &&
conn->resume_from) { conn->resume_from) {
/********************************************************************** /**********************************************************************
* Resuming upload in HTTP means that we PUT or POST and that we have * Resuming upload in HTTP means that we PUT or POST and that we have
@ -597,8 +597,9 @@ CURLcode Curl_http(struct connectdata *conn)
data->customrequest?data->customrequest: data->customrequest?data->customrequest:
(data->bits.no_body?"HEAD": (data->bits.no_body?"HEAD":
(data->bits.http_post || data->bits.http_formpost)?"POST": ((HTTPREQ_POST == data->httpreq) ||
(data->bits.http_put)?"PUT":"GET"), (HTTPREQ_POST_FORM == data->httpreq))?"POST":
(HTTPREQ_PUT == data->httpreq)?"PUT":"GET"),
ppath, ppath,
(conn->bits.proxy_user_passwd && (conn->bits.proxy_user_passwd &&
conn->allocptr.proxyuserpwd)?conn->allocptr.proxyuserpwd:"", conn->allocptr.proxyuserpwd)?conn->allocptr.proxyuserpwd:"",
@ -703,7 +704,7 @@ CURLcode Curl_http(struct connectdata *conn)
headers = headers->next; headers = headers->next;
} }
if(data->bits.http_formpost) { if(HTTPREQ_POST_FORM == data->httpreq) {
if(Curl_FormInit(&http->form, http->sendit)) { if(Curl_FormInit(&http->form, http->sendit)) {
failf(data, "Internal HTTP POST error!\n"); failf(data, "Internal HTTP POST error!\n");
return CURLE_HTTP_POST_ERROR; return CURLE_HTTP_POST_ERROR;
@ -734,7 +735,7 @@ CURLcode Curl_http(struct connectdata *conn)
return result; return result;
} }
} }
else if(data->bits.http_put) { else if(HTTPREQ_PUT == data->httpreq) {
/* Let's PUT the data to the server! */ /* Let's PUT the data to the server! */
if(data->infilesize>0) { if(data->infilesize>0) {
@ -762,7 +763,7 @@ CURLcode Curl_http(struct connectdata *conn)
} }
else { else {
if(data->bits.http_post) { if(HTTPREQ_POST == data->httpreq) {
/* this is the simple POST, using x-www-form-urlencoded style */ /* this is the simple POST, using x-www-form-urlencoded style */
if(!checkheaders(data, "Content-Length:")) if(!checkheaders(data, "Content-Length:"))

Просмотреть файл

@ -1046,10 +1046,8 @@ CURLcode Curl_perform(CURL *curl)
case 303: /* See Other */ case 303: /* See Other */
/* Disable both types of POSTs, since doing a second POST when /* Disable both types of POSTs, since doing a second POST when
* following isn't what anyone would want! */ * following isn't what anyone would want! */
data->bits.http_post = FALSE; data->httpreq = HTTPREQ_GET; /* enforce GET request */
data->bits.http_formpost = FALSE; infof(data, "Disables POST, goes with GET\n");
data->httpreq = HTTPREQ_GET; /* enfore GET request */
infof(data, "Disables POST\n");
break; break;
case 304: /* Not Modified */ case 304: /* Not Modified */
/* 304 means we did a conditional request and it was "Not modified". /* 304 means we did a conditional request and it was "Not modified".

Просмотреть файл

@ -432,10 +432,10 @@ CURLcode Curl_setopt(CURL *curl, CURLoption option, ...)
break; break;
case CURLOPT_PUT: case CURLOPT_PUT:
/* /*
* Use the HTTP PUT request to transfer data. * Use the HTTP PUT request to transfer data if this is TRUE. If this is
* FALSE, don't set the httpreq. We can't know what to revert it to!
*/ */
data->bits.http_put = va_arg(param, long)?TRUE:FALSE; if(va_arg(param, long))
if(data->bits.http_put)
data->httpreq = HTTPREQ_PUT; data->httpreq = HTTPREQ_PUT;
break; break;
#if 0 #if 0
@ -529,10 +529,18 @@ CURLcode Curl_setopt(CURL *curl, CURLoption option, ...)
* Set to make us do HTTP POST * Set to make us do HTTP POST
*/ */
data->httppost = va_arg(param, struct HttpPost *); data->httppost = va_arg(param, struct HttpPost *);
data->bits.http_formpost = data->httppost?1:0; if(data->httppost)
if(data->bits.http_formpost)
data->httpreq = HTTPREQ_POST_FORM; data->httpreq = HTTPREQ_POST_FORM;
break; break;
case CURLOPT_HTTPGET:
/*
* Set to force us do HTTP GET
*/
if(va_arg(param, long))
data->httpreq = HTTPREQ_GET;
break;
case CURLOPT_INFILE: case CURLOPT_INFILE:
/* /*
* FILE pointer to read the file to be uploaded from. Or possibly * FILE pointer to read the file to be uploaded from. Or possibly
@ -575,8 +583,8 @@ CURLcode Curl_setopt(CURL *curl, CURLoption option, ...)
break; break;
case CURLOPT_POST: case CURLOPT_POST:
/* Does this option serve a purpose anymore? */ /* Does this option serve a purpose anymore? */
data->bits.http_post = va_arg(param, long)?TRUE:FALSE;
if(data->bits.http_post) if(va_arg(param, long))
data->httpreq = HTTPREQ_POST; data->httpreq = HTTPREQ_POST;
break; break;
case CURLOPT_POSTFIELDS: case CURLOPT_POSTFIELDS:
@ -584,8 +592,7 @@ CURLcode Curl_setopt(CURL *curl, CURLoption option, ...)
* A string with POST data. Makes curl HTTP POST. * A string with POST data. Makes curl HTTP POST.
*/ */
data->postfields = va_arg(param, char *); data->postfields = va_arg(param, char *);
data->bits.http_post = data->postfields?TRUE:FALSE; if(data->postfields)
if(data->bits.http_post)
data->httpreq = HTTPREQ_POST; data->httpreq = HTTPREQ_POST;
break; break;
case CURLOPT_POSTFIELDSIZE: case CURLOPT_POSTFIELDSIZE:

Просмотреть файл

@ -382,12 +382,6 @@ typedef enum {
/* This struct is for boolean settings that define how to behave during /* This struct is for boolean settings that define how to behave during
this session. */ this session. */
struct Configbits { struct Configbits {
/* these four request types mirror the httpreq field */
bool http_formpost;
bool http_post;
bool http_put;
bool http_get;
bool get_filetime; bool get_filetime;
bool tunnel_thru_httpproxy; bool tunnel_thru_httpproxy;
bool ftp_append; bool ftp_append;