commit 5b7eec5d2d858dd33aa7f65a7655de1410154f0a
parent 98f89b072fe81041aa996eb388ca64f6d57f56cc
Author: Christian Grothoff <christian@grothoff.org>
Date: Tue, 7 Aug 2007 07:08:15 +0000
post fixes
Diffstat:
2 files changed, 45 insertions(+), 11 deletions(-)
diff --git a/src/daemon/connection.c b/src/daemon/connection.c
@@ -111,7 +111,7 @@ MHD_queue_response(struct MHD_Connection * connection,
(connection->response != NULL) ||
(connection->bodyReceived == 0) ||
(connection->headersReceived == 0) )
- return MHD_NO;
+ return MHD_NO;
MHD_increment_response_rc(response);
connection->response = response;
connection->responseCode = status_code;
@@ -552,6 +552,9 @@ MHD_call_connection_handler(struct MHD_Connection * connection) {
abort(); /* bad timing... */
ah = MHD_find_access_handler(connection);
processed = connection->readLoc;
+ /* FIXME: in case of POST, we need to
+ process the POST data here as well
+ (adding to the header list! */
if (MHD_NO == ah->dh(ah->dh_cls,
connection,
connection->url,
@@ -766,7 +769,7 @@ MHD_connection_handle_write(struct MHD_Connection * connection) {
}
return MHD_YES;
}
- if (response->total_size <= connection->messagePos)
+ if (response->total_size < connection->messagePos)
abort(); /* internal error */
if (response->crc != NULL)
pthread_mutex_lock(&response->mutex);
diff --git a/src/daemon/daemontest_post.c b/src/daemon/daemontest_post.c
@@ -37,6 +37,9 @@
#include <string.h>
#include <time.h>
+#define POST_DATA "name=daniel&project=curl"
+
+
static int apc_all(void * cls,
const struct sockaddr * addr,
socklen_t addrlen) {
@@ -78,6 +81,25 @@ static int ahc_echo(void * cls,
printf("METHOD: %s\n", method);
return MHD_NO; /* unexpected method */
}
+ if ( (*upload_data_size < 24) &&
+ (*upload_data_size > 0) )
+ return MHD_YES; /* continue */
+ if (*upload_data_size == 24) {
+ *upload_data_size = 0;
+ if ( (0 != strcmp("daniel",
+ MHD_lookup_connection_value(connection,
+ MHD_POSTDATA_KIND,
+ "name"))) ||
+ (0 != strcmp("curl",
+ MHD_lookup_connection_value(connection,
+ MHD_POSTDATA_KIND,
+ "project"))) ) {
+ printf("POST DATA not processed correctly!\n");
+ return MHD_NO;
+ }
+
+ return MHD_YES; /* continue */
+ }
/* FIXME: check connection headers... */
response = MHD_create_response_from_data(strlen(url),
(void*) url,
@@ -119,9 +141,12 @@ static int testInternalPost() {
curl_easy_setopt(c,
CURLOPT_WRITEDATA,
&cbc);
- curl_easy_setopt(c,
- CURLOPT_HTTPPOST,
- NULL); /* FIXME! */
+ curl_easy_setopt(c,
+ CURLOPT_POSTFIELDS,
+ POST_DATA);
+ curl_easy_setopt(c,
+ CURLOPT_POSTFIELDSIZE,
+ strlen(POST_DATA));
curl_easy_setopt(c,
CURLOPT_POST,
1L);
@@ -193,9 +218,12 @@ static int testMultithreadedPost() {
curl_easy_setopt(c,
CURLOPT_WRITEDATA,
&cbc);
- curl_easy_setopt(c,
- CURLOPT_HTTPPOST,
- NULL); /* FIXME! */
+ curl_easy_setopt(c,
+ CURLOPT_POSTFIELDS,
+ POST_DATA);
+ curl_easy_setopt(c,
+ CURLOPT_POSTFIELDSIZE,
+ strlen(POST_DATA));
curl_easy_setopt(c,
CURLOPT_POST,
1L);
@@ -278,9 +306,12 @@ static int testExternalPost() {
curl_easy_setopt(c,
CURLOPT_WRITEDATA,
&cbc);
- curl_easy_setopt(c,
- CURLOPT_HTTPPOST,
- NULL); /* FIXME! */
+ curl_easy_setopt(c,
+ CURLOPT_POSTFIELDS,
+ POST_DATA);
+ curl_easy_setopt(c,
+ CURLOPT_POSTFIELDSIZE,
+ strlen(POST_DATA));
curl_easy_setopt(c,
CURLOPT_POST,
1L);