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 /src/daemon | |
parent | 5c965b262ec2ef91cb860ef1320b8558033ae8a2 (diff) | |
download | libmicrohttpd-a9366e931500a3ee1ac6ed30edbdcea708dcdcd8.tar.gz libmicrohttpd-a9366e931500a3ee1ac6ed30edbdcea708dcdcd8.zip |
mantis 1263
Diffstat (limited to 'src/daemon')
-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 |
4 files changed, 74 insertions, 4 deletions
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 = \ | |||
33 | daemontest_get \ | 33 | daemontest_get \ |
34 | daemontest_post \ | 34 | daemontest_post \ |
35 | daemontest_put \ | 35 | daemontest_put \ |
36 | daemontest_get11 \ | ||
36 | daemontest_post11 \ | 37 | daemontest_post11 \ |
37 | daemontest_put11 | 38 | daemontest_put11 |
38 | 39 | ||
@@ -61,6 +62,12 @@ daemontest_put_LDADD = \ | |||
61 | $(top_builddir)/src/daemon/libmicrohttpd.la \ | 62 | $(top_builddir)/src/daemon/libmicrohttpd.la \ |
62 | @LIBCURL@ | 63 | @LIBCURL@ |
63 | 64 | ||
65 | daemontest_get11_SOURCES = \ | ||
66 | daemontest_get.c | ||
67 | daemontest_get11_LDADD = \ | ||
68 | $(top_builddir)/src/daemon/libmicrohttpd.la \ | ||
69 | @LIBCURL@ | ||
70 | |||
64 | daemontest_post11_SOURCES = \ | 71 | daemontest_post11_SOURCES = \ |
65 | daemontest_post.c | 72 | daemontest_post.c |
66 | daemontest_post11_LDADD = \ | 73 | 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 @@ | |||
35 | */ | 35 | */ |
36 | #define MHD_BUF_INC_SIZE 2048 | 36 | #define MHD_BUF_INC_SIZE 2048 |
37 | 37 | ||
38 | /** | ||
39 | * Message to transmit when http 1.1 request is received | ||
40 | */ | ||
41 | #define HTTP_100_CONTINUE "HTTP/1.1 100 Continue\r\n\r\n" | ||
38 | 42 | ||
39 | /** | 43 | /** |
40 | * Get all of the headers from the request. | 44 | * Get all of the headers from the request. |
@@ -170,7 +174,11 @@ MHD_connection_get_fdset(struct MHD_Connection * connection, | |||
170 | } | 174 | } |
171 | } | 175 | } |
172 | } | 176 | } |
173 | if (connection->response != NULL) { | 177 | if ( (connection->response != NULL) || |
178 | ( (connection->version != NULL) && | ||
179 | (0 == strcasecmp(connection->version, | ||
180 | MHD_HTTP_VERSION_1_1)) && | ||
181 | (connection->continuePos < strlen(HTTP_100_CONTINUE)) ) ) { | ||
174 | FD_SET(fd, write_fd_set); | 182 | FD_SET(fd, write_fd_set); |
175 | if (fd > *max_fd) | 183 | if (fd > *max_fd) |
176 | *max_fd = fd; | 184 | *max_fd = fd; |
@@ -921,6 +929,27 @@ MHD_connection_handle_write(struct MHD_Connection * connection) { | |||
921 | struct MHD_Response * response; | 929 | struct MHD_Response * response; |
922 | int ret; | 930 | int ret; |
923 | 931 | ||
932 | if ( (connection->version != NULL) && | ||
933 | (0 == strcasecmp(connection->version, | ||
934 | MHD_HTTP_VERSION_1_1)) && | ||
935 | (connection->continuePos < strlen(HTTP_100_CONTINUE)) ) { | ||
936 | ret = SEND(connection->socket_fd, | ||
937 | &HTTP_100_CONTINUE[connection->continuePos], | ||
938 | strlen(HTTP_100_CONTINUE) - connection->continuePos, | ||
939 | 0); | ||
940 | if (ret < 0) { | ||
941 | if (errno == EINTR) | ||
942 | return MHD_YES; | ||
943 | MHD_DLOG(connection->daemon, | ||
944 | "Failed to send data: %s\n", | ||
945 | STRERROR(errno)); | ||
946 | CLOSE(connection->socket_fd); | ||
947 | connection->socket_fd = -1; | ||
948 | return MHD_YES; | ||
949 | } | ||
950 | connection->continuePos += ret; | ||
951 | return MHD_YES; | ||
952 | } | ||
924 | response = connection->response; | 953 | response = connection->response; |
925 | if(response == NULL) { | 954 | if(response == NULL) { |
926 | MHD_DLOG(connection->daemon, | 955 | MHD_DLOG(connection->daemon, |
@@ -1027,6 +1056,7 @@ MHD_connection_handle_write(struct MHD_Connection * connection) { | |||
1027 | (connection->headersReceived == 0) ) | 1056 | (connection->headersReceived == 0) ) |
1028 | abort(); /* internal error */ | 1057 | abort(); /* internal error */ |
1029 | MHD_destroy_response(response); | 1058 | MHD_destroy_response(response); |
1059 | connection->continuePos = 0; | ||
1030 | connection->responseCode = 0; | 1060 | connection->responseCode = 0; |
1031 | connection->response = NULL; | 1061 | connection->response = NULL; |
1032 | connection->headersReceived = 0; | 1062 | 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 @@ | |||
33 | #include <string.h> | 33 | #include <string.h> |
34 | #include <time.h> | 34 | #include <time.h> |
35 | 35 | ||
36 | static int oneone; | ||
37 | |||
36 | static int apc_all(void * cls, | 38 | static int apc_all(void * cls, |
37 | const struct sockaddr * addr, | 39 | const struct sockaddr * addr, |
38 | socklen_t addrlen) { | 40 | socklen_t addrlen) { |
@@ -122,7 +124,15 @@ static int testInternalGet() { | |||
122 | curl_easy_setopt(c, | 124 | curl_easy_setopt(c, |
123 | CURLOPT_CONNECTTIMEOUT, | 125 | CURLOPT_CONNECTTIMEOUT, |
124 | 2L); | 126 | 2L); |
125 | // NOTE: use of CONNECTTIMEOUT without also | 127 | if (oneone) |
128 | curl_easy_setopt(c, | ||
129 | CURLOPT_HTTP_VERSION, | ||
130 | CURL_HTTP_VERSION_1_1); | ||
131 | else | ||
132 | curl_easy_setopt(c, | ||
133 | CURLOPT_HTTP_VERSION, | ||
134 | CURL_HTTP_VERSION_1_0); | ||
135 | // NOTE: use of CONNECTTIMEOUT without also | ||
126 | // setting NOSIGNAL results in really weird | 136 | // setting NOSIGNAL results in really weird |
127 | // crashes on my system! | 137 | // crashes on my system! |
128 | curl_easy_setopt(c, | 138 | curl_easy_setopt(c, |
@@ -184,7 +194,15 @@ static int testMultithreadedGet() { | |||
184 | curl_easy_setopt(c, | 194 | curl_easy_setopt(c, |
185 | CURLOPT_TIMEOUT, | 195 | CURLOPT_TIMEOUT, |
186 | 2L); | 196 | 2L); |
187 | curl_easy_setopt(c, | 197 | if (oneone) |
198 | curl_easy_setopt(c, | ||
199 | CURLOPT_HTTP_VERSION, | ||
200 | CURL_HTTP_VERSION_1_1); | ||
201 | else | ||
202 | curl_easy_setopt(c, | ||
203 | CURLOPT_HTTP_VERSION, | ||
204 | CURL_HTTP_VERSION_1_0); | ||
205 | curl_easy_setopt(c, | ||
188 | CURLOPT_CONNECTTIMEOUT, | 206 | CURLOPT_CONNECTTIMEOUT, |
189 | 2L); | 207 | 2L); |
190 | // NOTE: use of CONNECTTIMEOUT without also | 208 | // NOTE: use of CONNECTTIMEOUT without also |
@@ -256,7 +274,15 @@ static int testExternalGet() { | |||
256 | curl_easy_setopt(c, | 274 | curl_easy_setopt(c, |
257 | CURLOPT_FAILONERROR, | 275 | CURLOPT_FAILONERROR, |
258 | 1); | 276 | 1); |
259 | curl_easy_setopt(c, | 277 | if (oneone) |
278 | curl_easy_setopt(c, | ||
279 | CURLOPT_HTTP_VERSION, | ||
280 | CURL_HTTP_VERSION_1_1); | ||
281 | else | ||
282 | curl_easy_setopt(c, | ||
283 | CURLOPT_HTTP_VERSION, | ||
284 | CURL_HTTP_VERSION_1_0); | ||
285 | curl_easy_setopt(c, | ||
260 | CURLOPT_TIMEOUT, | 286 | CURLOPT_TIMEOUT, |
261 | 5L); | 287 | 5L); |
262 | curl_easy_setopt(c, | 288 | curl_easy_setopt(c, |
@@ -364,6 +390,7 @@ int main(int argc, | |||
364 | char * const * argv) { | 390 | char * const * argv) { |
365 | unsigned int errorCount = 0; | 391 | unsigned int errorCount = 0; |
366 | 392 | ||
393 | oneone = NULL != strstr(argv[0], "11"); | ||
367 | if (0 != curl_global_init(CURL_GLOBAL_WIN32)) | 394 | if (0 != curl_global_init(CURL_GLOBAL_WIN32)) |
368 | return 2; | 395 | return 2; |
369 | errorCount += testInternalGet(); | 396 | 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 { | |||
272 | size_t uploadSize; | 272 | size_t uploadSize; |
273 | 273 | ||
274 | /** | 274 | /** |
275 | * Position in the 100 CONTINUE message that | ||
276 | * we need to send when receiving http 1.1 requests. | ||
277 | */ | ||
278 | size_t continuePos; | ||
279 | |||
280 | /** | ||
275 | * Length of the foreign address. | 281 | * Length of the foreign address. |
276 | */ | 282 | */ |
277 | socklen_t addr_len; | 283 | socklen_t addr_len; |