aboutsummaryrefslogtreecommitdiff
path: root/src/daemon/connection.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/daemon/connection.c')
-rw-r--r--src/daemon/connection.c44
1 files changed, 39 insertions, 5 deletions
diff --git a/src/daemon/connection.c b/src/daemon/connection.c
index e51693d9..cdc8540b 100644
--- a/src/daemon/connection.c
+++ b/src/daemon/connection.c
@@ -37,12 +37,24 @@
37#define HTTP_100_CONTINUE "HTTP/1.1 100 Continue\r\n\r\n" 37#define HTTP_100_CONTINUE "HTTP/1.1 100 Continue\r\n\r\n"
38 38
39/** 39/**
40 * Response used when the request (http header) is too big to 40 * Response text used when the request (http header) is too big to
41 * be processed. 41 * be processed.
42 *
43 * Intentionally empty here to keep our memory footprint
44 * minimal.
42 */ 45 */
43#define REQUEST_TOO_BIG "" 46#define REQUEST_TOO_BIG ""
44 47
45/** 48/**
49 * Response text used when the request (http header) does not
50 * contain a "Host:" header and still claims to be HTTP 1.1.
51 *
52 * Intentionally empty here to keep our memory footprint
53 * minimal.
54 */
55#define REQUEST_LACKS_HOST ""
56
57/**
46 * Add extra debug messages with reasons for closing connections 58 * Add extra debug messages with reasons for closing connections
47 * (non-error reasons). 59 * (non-error reasons).
48 */ 60 */
@@ -305,9 +317,7 @@ MHD_excessive_data_handler (struct MHD_Connection *connection,
305{ 317{
306 struct MHD_Response *response; 318 struct MHD_Response *response;
307 319
308 /* die, header far too long to be reasonable; 320 /* die, header far too long to be reasonable */
309 FIXME: send proper response to client
310 (stop reading, queue proper response) */
311 connection->read_close = MHD_YES; 321 connection->read_close = MHD_YES;
312 connection->headersReceived = MHD_YES; 322 connection->headersReceived = MHD_YES;
313 connection->bodyReceived = MHD_YES; 323 connection->bodyReceived = MHD_YES;
@@ -589,6 +599,7 @@ MHD_parse_connection_headers (struct MHD_Connection *connection)
589 const char *clen; 599 const char *clen;
590 const char *end; 600 const char *end;
591 unsigned long long cval; 601 unsigned long long cval;
602 struct MHD_Response * response;
592 603
593 if (connection->bodyReceived == 1) 604 if (connection->bodyReceived == 1)
594 abort (); 605 abort ();
@@ -638,7 +649,7 @@ MHD_parse_connection_headers (struct MHD_Connection *connection)
638 if (strlen (line) == 0) 649 if (strlen (line) == 0)
639 { 650 {
640 /* end of header */ 651 /* end of header */
641 connection->headersReceived = 1; 652 connection->headersReceived = MHD_YES;
642 clen = MHD_lookup_connection_value (connection, 653 clen = MHD_lookup_connection_value (connection,
643 MHD_HEADER_KIND, 654 MHD_HEADER_KIND,
644 MHD_HTTP_HEADER_CONTENT_LENGTH); 655 MHD_HTTP_HEADER_CONTENT_LENGTH);
@@ -680,6 +691,29 @@ MHD_parse_connection_headers (struct MHD_Connection *connection)
680 this request */ 691 this request */
681 connection->read_close = MHD_YES; 692 connection->read_close = MHD_YES;
682 } 693 }
694
695 if ( (0 != (MHD_USE_PEDANTIC_CHECKS & connection->daemon->options)) &&
696 (NULL != connection->version) &&
697 (0 == strcasecmp(MHD_HTTP_VERSION_1_1,
698 connection->version)) &&
699 (NULL == MHD_lookup_connection_value(connection,
700 MHD_HEADER_KIND,
701 MHD_HTTP_HEADER_HOST)) ) {
702 /* die, http 1.1 request without host and we are pedantic */
703 connection->bodyReceived = MHD_YES;
704 connection->read_close = MHD_YES;
705 MHD_DLOG (connection->daemon,
706 "Received `%s' request without `%s' header.\n",
707 MHD_HTTP_VERSION_1_1,
708 MHD_HTTP_HEADER_HOST);
709 response = MHD_create_response_from_data (strlen (REQUEST_LACKS_HOST),
710 REQUEST_LACKS_HOST, MHD_NO, MHD_NO);
711 MHD_queue_response (connection,
712 MHD_HTTP_BAD_REQUEST,
713 response);
714 MHD_destroy_response (response);
715 }
716
683 break; 717 break;
684 } 718 }
685 /* line should be normal header line, find colon */ 719 /* line should be normal header line, find colon */