diff options
Diffstat (limited to 'src/daemon/connection.c')
-rw-r--r-- | src/daemon/connection.c | 32 |
1 files changed, 31 insertions, 1 deletions
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; |