aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2000-06-14 17:15:07 +0000
committerDaniel Stenberg <daniel@haxx.se>2000-06-14 17:15:07 +0000
commit94ec5ff44a78921a11803d33b3065d2d5322cf6d (patch)
tree9b00dafad6fec84495e29bba6c2b8fe725784d67 /lib
parente54f09a2186c21b787ac4c88c26d5a1d0aaf2d7b (diff)
correct the POST workings. Tim Tassonis reported.
Diffstat (limited to 'lib')
-rw-r--r--lib/http.c70
1 files changed, 34 insertions, 36 deletions
diff --git a/lib/http.c b/lib/http.c
index b6b87f905..60869d6d8 100644
--- a/lib/http.c
+++ b/lib/http.c
@@ -209,7 +209,7 @@ CURLcode http(struct connectdata *conn)
{
struct UrlData *data=conn->data;
char *buf = data->buffer; /* this is a short cut to the buffer */
- CURLcode result;
+ CURLcode result=CURLE_OK;
struct HTTP *http;
struct Cookie *co=NULL; /* no cookies from start */
char *ppath = conn->ppath; /* three previous function arguments */
@@ -370,46 +370,34 @@ CURLcode http(struct connectdata *conn)
headers = headers->next;
}
- if(data->bits.http_post || data->bits.http_formpost) {
- if(data->bits.http_post) {
- /* this is the simple x-www-form-urlencoded style */
- sendf(data->firstsocket, data,
- "Content-Length: %d\015\012"
- "Content-Type: application/x-www-form-urlencoded\r\n\r\n"
- "%s\015\012",
- strlen(data->postfields),
- data->postfields );
+ if(data->bits.http_formpost) {
+ if(FormInit(&http->form, http->sendit)) {
+ failf(data, "Internal HTTP POST error!\n");
+ return CURLE_HTTP_POST_ERROR;
}
- else {
- if(FormInit(&http->form, http->sendit)) {
- failf(data, "Internal HTTP POST error!\n");
- return CURLE_HTTP_POST_ERROR;
- }
-
- http->storefread = data->fread; /* backup */
- http->in = data->in; /* backup */
+ http->storefread = data->fread; /* backup */
+ http->in = data->in; /* backup */
- data->fread =
- (size_t (*)(char *, size_t, size_t, FILE *))
- FormReader; /* set the read function to read from the
- generated form data */
- data->in = (FILE *)&http->form;
+ data->fread =
+ (size_t (*)(char *, size_t, size_t, FILE *))
+ FormReader; /* set the read function to read from the
+ generated form data */
+ data->in = (FILE *)&http->form;
- sendf(data->firstsocket, data,
- "Content-Length: %d\r\n",
- http->postsize-2);
+ sendf(data->firstsocket, data,
+ "Content-Length: %d\r\n",
+ http->postsize-2);
- pgrsSetUploadSize(data, http->postsize);
+ pgrsSetUploadSize(data, http->postsize);
- result = Transfer(conn, data->firstsocket, -1, TRUE,
- &http->readbytecount,
+ result = Transfer(conn, data->firstsocket, -1, TRUE,
+ &http->readbytecount,
data->firstsocket,
- &http->writebytecount);
- if(result) {
- FormFree(http->sendit); /* free that whole lot */
- return result;
- }
+ &http->writebytecount);
+ if(result) {
+ FormFree(http->sendit); /* free that whole lot */
+ return result;
}
}
else if(data->bits.http_put) {
@@ -432,10 +420,20 @@ CURLcode http(struct connectdata *conn)
&http->writebytecount);
if(result)
return result;
-
+
}
else {
- sendf(data->firstsocket, data, "\r\n");
+ if(data->bits.http_post) {
+ /* this is the simple x-www-form-urlencoded style */
+ sendf(data->firstsocket, data,
+ "Content-Length: %d\015\012"
+ "Content-Type: application/x-www-form-urlencoded\r\n\r\n"
+ "%s\r\n",
+ strlen(data->postfields),
+ data->postfields );
+ }
+ else
+ sendf(data->firstsocket, data, "\r\n");
/* HTTP GET/HEAD download: */
result = Transfer(conn, data->firstsocket, -1, TRUE, bytecount,