diff options
author | Christian Grothoff <christian@grothoff.org> | 2007-08-08 08:55:18 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2007-08-08 08:55:18 +0000 |
commit | a9366e931500a3ee1ac6ed30edbdcea708dcdcd8 (patch) | |
tree | d5251451d69c3a60285239b101828bcc084b8eb6 | |
parent | 5c965b262ec2ef91cb860ef1320b8558033ae8a2 (diff) |
mantis 1263
-rw-r--r-- | README | 13 | ||||
-rw-r--r-- | src/daemon/Makefile.am | 7 | ||||
-rw-r--r-- | src/daemon/connection.c | 32 | ||||
-rw-r--r-- | src/daemon/daemontest_get.c | 33 | ||||
-rw-r--r-- | src/daemon/internal.h | 6 |
5 files changed, 81 insertions, 10 deletions
@@ -6,24 +6,25 @@ reasonably complete. #XXXX refers to the respective Mantis bug report (or feature request). ARCH indicates that implementing this feature may require non-trivial ARCHitectural changes in the code. API indicates that implementing the feature will require API changes. -TRIV indicates that implementing this feature should be TRIVial. +TRIV indicates that implementing this feature should be TRIVial. TEST +indicates that a testcase should be written before implementing the +feature. For http/1.1-compliance: ======================== connection.c: -- support responding immediately with "100 CONTINUE" (http 1.1) (#1263, ARCH) - send proper error code back if headers are too long - (currently, we just close the connection) (#1222, ARCH) -- support chunked requests from clients (#1260, ARCH) + (currently, we just close the connection) (#1222, ARCH, TEST) +- support chunked requests from clients (#1260, TEST, TEST) - send proper error code back if client forgot the "Host" header (#1264, TRIV) - automatically add MHD_HTTP_HEADER_DATE if client "forgot" to add one (#1261, TRIV) - automatically drop body from responses to "HEAD" requests (#1262, TRIV) For POST: ========= -- find better way to handle POST data that does not fit into memory (#1221, API) -- add support to decode multipart/form-data (#1221) +- find better way to handle POST data that does not fit into memory (#1221, API, TEST) +- add support to decode multipart/form-data (#1221, TEST) For SSL: ======== diff --git a/src/daemon/Makefile.am b/src/daemon/Makefile.am index e0174f40..e02b2c7d 100644 --- a/src/daemon/Makefile.am +++ b/src/daemon/Makefile.am @@ -33,6 +33,7 @@ check_PROGRAMS = \ daemontest_get \ daemontest_post \ daemontest_put \ + daemontest_get11 \ daemontest_post11 \ daemontest_put11 @@ -61,6 +62,12 @@ daemontest_put_LDADD = \ $(top_builddir)/src/daemon/libmicrohttpd.la \ @LIBCURL@ +daemontest_get11_SOURCES = \ + daemontest_get.c +daemontest_get11_LDADD = \ + $(top_builddir)/src/daemon/libmicrohttpd.la \ + @LIBCURL@ + daemontest_post11_SOURCES = \ daemontest_post.c daemontest_post11_LDADD = \ diff --git a/src/daemon/connection.c b/src/daemon/connection.c index bb3d8990..272fb802 100644 --- a/src/daemon/connection.c +++ b/src/daemon/connection.c @@ -35,6 +35,10 @@ */ #define MHD_BUF_INC_SIZE 2048 +/** + * Message to transmit when http 1.1 request is received + */ +#define HTTP_100_CONTINUE "HTTP/1.1 100 Continue\r\n\r\n" /** * Get all of the headers from the request. @@ -170,7 +174,11 @@ MHD_connection_get_fdset(struct MHD_Connection * connection, } } } - if (connection->response != NULL) { + if ( (connection->response != NULL) || + ( (connection->version != NULL) && + (0 == strcasecmp(connection->version, + MHD_HTTP_VERSION_1_1)) && + (connection->continuePos < strlen(HTTP_100_CONTINUE)) ) ) { FD_SET(fd, write_fd_set); if (fd > *max_fd) *max_fd = fd; @@ -921,6 +929,27 @@ MHD_connection_handle_write(struct MHD_Connection * connection) { struct MHD_Response * response; int ret; + if ( (connection->version != NULL) && + (0 == strcasecmp(connection->version, + MHD_HTTP_VERSION_1_1)) && + (connection->continuePos < strlen(HTTP_100_CONTINUE)) ) { + ret = SEND(connection->socket_fd, + &HTTP_100_CONTINUE[connection->continuePos], + strlen(HTTP_100_CONTINUE) - connection->continuePos, + 0); + if (ret < 0) { + if (errno == EINTR) + return MHD_YES; + MHD_DLOG(connection->daemon, + "Failed to send data: %s\n", + STRERROR(errno)); + CLOSE(connection->socket_fd); + connection->socket_fd = -1; + return MHD_YES; + } + connection->continuePos += ret; + return MHD_YES; + } response = connection->response; if(response == NULL) { MHD_DLOG(connection->daemon, @@ -1027,6 +1056,7 @@ MHD_connection_handle_write(struct MHD_Connection * connection) { (connection->headersReceived == 0) ) abort(); /* internal error */ MHD_destroy_response(response); + connection->continuePos = 0; connection->responseCode = 0; connection->response = NULL; connection->headersReceived = 0; diff --git a/src/daemon/daemontest_get.c b/src/daemon/daemontest_get.c index 3cd158ff..2366c281 100644 --- a/src/daemon/daemontest_get.c +++ b/src/daemon/daemontest_get.c @@ -33,6 +33,8 @@ #include <string.h> #include <time.h> +static int oneone; + static int apc_all(void * cls, const struct sockaddr * addr, socklen_t addrlen) { @@ -122,7 +124,15 @@ static int testInternalGet() { curl_easy_setopt(c, CURLOPT_CONNECTTIMEOUT, 2L); - // NOTE: use of CONNECTTIMEOUT without also + if (oneone) + curl_easy_setopt(c, + CURLOPT_HTTP_VERSION, + CURL_HTTP_VERSION_1_1); + else + curl_easy_setopt(c, + CURLOPT_HTTP_VERSION, + CURL_HTTP_VERSION_1_0); + // NOTE: use of CONNECTTIMEOUT without also // setting NOSIGNAL results in really weird // crashes on my system! curl_easy_setopt(c, @@ -184,7 +194,15 @@ static int testMultithreadedGet() { curl_easy_setopt(c, CURLOPT_TIMEOUT, 2L); - curl_easy_setopt(c, + if (oneone) + curl_easy_setopt(c, + CURLOPT_HTTP_VERSION, + CURL_HTTP_VERSION_1_1); + else + curl_easy_setopt(c, + CURLOPT_HTTP_VERSION, + CURL_HTTP_VERSION_1_0); + curl_easy_setopt(c, CURLOPT_CONNECTTIMEOUT, 2L); // NOTE: use of CONNECTTIMEOUT without also @@ -256,7 +274,15 @@ static int testExternalGet() { curl_easy_setopt(c, CURLOPT_FAILONERROR, 1); - curl_easy_setopt(c, + if (oneone) + curl_easy_setopt(c, + CURLOPT_HTTP_VERSION, + CURL_HTTP_VERSION_1_1); + else + curl_easy_setopt(c, + CURLOPT_HTTP_VERSION, + CURL_HTTP_VERSION_1_0); + curl_easy_setopt(c, CURLOPT_TIMEOUT, 5L); curl_easy_setopt(c, @@ -364,6 +390,7 @@ int main(int argc, char * const * argv) { unsigned int errorCount = 0; + oneone = NULL != strstr(argv[0], "11"); if (0 != curl_global_init(CURL_GLOBAL_WIN32)) return 2; errorCount += testInternalGet(); diff --git a/src/daemon/internal.h b/src/daemon/internal.h index efadb33a..1c3525f6 100644 --- a/src/daemon/internal.h +++ b/src/daemon/internal.h @@ -272,6 +272,12 @@ struct MHD_Connection { size_t uploadSize; /** + * Position in the 100 CONTINUE message that + * we need to send when receiving http 1.1 requests. + */ + size_t continuePos; + + /** * Length of the foreign address. */ socklen_t addr_len; |