1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-21 23:58:49 -05:00

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,23 +913,11 @@ CURLcode Curl_http(struct connectdata *conn)
&http->writebytecount);
if(result)
return result;
break;
}
else {
if(HTTPREQ_POST == data->set.httpreq) {
case HTTPREQ_POST:
/* this is the simple POST, using x-www-form-urlencoded style */
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! */
}
if(!checkheaders(data, "Content-Length:"))
/* we allow replacing this header, although it isn't very wise to
actually set your own */
@ -940,20 +930,32 @@ CURLcode Curl_http(struct connectdata *conn)
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);
/* and here comes the actual data */
if(data->set.postfieldsize && data->set.postfields) {
add_buffer(req_buffer, data->set.postfields,
data->set.postfieldsize);
}
else {
else if(data->set.postfields)
add_bufferf(req_buffer,
"\r\n"
"%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 */