if CURLOPT_POSTFIELDS isn't set, but CURLOPT_POST is, we will assume that

we should read the POST-data from the read callback
This commit is contained in:
Daniel Stenberg 2002-03-14 14:39:23 +00:00
parent cfdb6f851c
commit 468b787272

View File

@ -814,7 +814,9 @@ CURLcode Curl_http(struct connectdata *conn)
headers = headers->next;
}
if(HTTPREQ_POST_FORM == data->set.httpreq) {
switch(data->set.httpreq) {
case HTTPREQ_POST_FORM:
if(Curl_FormInit(&http->form, http->sendit)) {
failf(data, "Internal HTTP POST error!");
return CURLE_HTTP_POST_ERROR;
@ -883,9 +885,9 @@ CURLcode Curl_http(struct connectdata *conn)
Curl_formclean(http->sendit); /* free that whole lot */
return result;
}
}
else if(HTTPREQ_PUT == data->set.httpreq) {
/* Let's PUT the data to the server! */
break;
case HTTPREQ_PUT: /* Let's PUT the data to the server! */
if(data->set.infilesize>0) {
add_bufferf(req_buffer,
@ -911,51 +913,51 @@ CURLcode Curl_http(struct connectdata *conn)
&http->writebytecount);
if(result)
return result;
}
else {
if(HTTPREQ_POST == data->set.httpreq) {
/* this is the simple POST, using x-www-form-urlencoded style */
break;
if(!data->set.postfields) {
/*
* This is an attempt to do a POST without having anything to
* actually send. Let's make a NULL pointer equal "" here. Good/bad
* ?
*/
data->set.postfields = (char *)"";
data->set.postfieldsize = 0; /* it might been set to something illegal,
anything > 0 would be! */
}
case HTTPREQ_POST:
/* this is the simple POST, using x-www-form-urlencoded style */
if(!checkheaders(data, "Content-Length:"))
/* we allow replacing this header, although it isn't very wise to
actually set your own */
add_bufferf(req_buffer,
"Content-Length: %d\r\n",
(data->set.postfieldsize?data->set.postfieldsize:
strlen(data->set.postfields)) );
if(!checkheaders(data, "Content-Length:"))
/* we allow replacing this header, although it isn't very wise to
actually set your own */
add_bufferf(req_buffer,
"Content-Length: %d\r\n",
(data->set.postfieldsize?data->set.postfieldsize:
strlen(data->set.postfields)) );
if(!checkheaders(data, "Content-Type:"))
add_bufferf(req_buffer,
"Content-Type: application/x-www-form-urlencoded\r\n");
if(!checkheaders(data, "Content-Type:"))
add_bufferf(req_buffer,
"Content-Type: application/x-www-form-urlencoded\r\n");
/* and here comes the actual data */
if(data->set.postfieldsize) {
add_buffer(req_buffer, "\r\n", 2);
add_buffer(req_buffer, data->set.postfields,
data->set.postfieldsize);
}
else {
add_bufferf(req_buffer,
"\r\n"
"%s",
data->set.postfields );
}
add_buffer(req_buffer, "\r\n", 2);
/* and here comes the actual data */
if(data->set.postfieldsize && data->set.postfields) {
add_buffer(req_buffer, data->set.postfields,
data->set.postfieldsize);
}
else
add_buffer(req_buffer, "\r\n", 2);
else if(data->set.postfields)
add_bufferf(req_buffer,
"%s",
data->set.postfields );
/* issue the request */
result = add_buffer_send(conn->firstsocket, conn, req_buffer,
&data->info.request_size);
if(result)
failf(data, "Failed sending HTTP POST request");
else
result =
Curl_Transfer(conn, conn->firstsocket, -1, TRUE, bytecount,
data->set.postfields?-1:conn->firstsocket,
data->set.postfields?NULL:&http->writebytecount);
break;
default:
add_buffer(req_buffer, "\r\n", 2);
/* issue the request */
result = add_buffer_send(conn->firstsocket, conn, req_buffer,
&data->info.request_size);