mirror of
https://github.com/curl/curl.git
synced 2025-01-30 14:22:33 +08:00
Made it possible to replace the Content-Type: and Content-Length: headers
curl issues when doing a regular HTTP post. This should not be taken light- heartedly though. Replacing them might get you into trouble!
This commit is contained in:
parent
8fd44dd648
commit
349a3aaf5b
19
lib/http.c
19
lib/http.c
@ -481,12 +481,23 @@ CURLcode http(struct connectdata *conn)
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(data->bits.http_post) {
|
if(data->bits.http_post) {
|
||||||
/* this is the simple x-www-form-urlencoded style */
|
/* 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 */
|
||||||
sendf(data->firstsocket, data,
|
sendf(data->firstsocket, data,
|
||||||
"Content-Length: %d\015\012"
|
"Content-Length: %d\r\n",
|
||||||
"Content-Type: application/x-www-form-urlencoded\r\n\r\n"
|
strlen(data->postfields));
|
||||||
|
|
||||||
|
if(!checkheaders(data, "Content-Type:"))
|
||||||
|
sendf(data->firstsocket, data,
|
||||||
|
"Content-Type: application/x-www-form-urlencoded\r\n");
|
||||||
|
|
||||||
|
/* and here comes the actual data */
|
||||||
|
sendf(data->firstsocket, data,
|
||||||
|
"\r\n"
|
||||||
"%s\r\n",
|
"%s\r\n",
|
||||||
strlen(data->postfields),
|
|
||||||
data->postfields );
|
data->postfields );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user