diff options
Diffstat (limited to 'src/microhttpd/connection.c')
-rw-r--r-- | src/microhttpd/connection.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c index 704d6bcf..19d1c699 100644 --- a/src/microhttpd/connection.c +++ b/src/microhttpd/connection.c | |||
@@ -103,6 +103,21 @@ | |||
103 | #endif | 103 | #endif |
104 | 104 | ||
105 | /** | 105 | /** |
106 | * Response text used when the request has unsupported both headers: | ||
107 | * "Transfer-Enconding:" and "Content-Length:" | ||
108 | */ | ||
109 | #ifdef HAVE_MESSAGES | ||
110 | #define REQUEST_LENGTH_WITH_TR_ENCODING \ | ||
111 | "<html>" \ | ||
112 | "<head><title>Malformed request</title></head>" \ | ||
113 | "<body>Wrong combination of the request headers: both Transfer-Encoding " \ | ||
114 | "and Content-Length headers are used at the same time.</body>" \ | ||
115 | "</html>" | ||
116 | #else | ||
117 | #define REQUEST_LENGTH_WITH_TR_ENCODING "" | ||
118 | #endif | ||
119 | |||
120 | /** | ||
106 | * Response text used when the request (http header) is | 121 | * Response text used when the request (http header) is |
107 | * malformed. | 122 | * malformed. |
108 | * | 123 | * |
@@ -3996,6 +4011,33 @@ parse_connection_headers (struct MHD_Connection *connection) | |||
3996 | REQUEST_UNSUPPORTED_TR_ENCODING); | 4011 | REQUEST_UNSUPPORTED_TR_ENCODING); |
3997 | return; | 4012 | return; |
3998 | } | 4013 | } |
4014 | else if (MHD_NO != | ||
4015 | MHD_lookup_connection_value_n (connection, | ||
4016 | MHD_HEADER_KIND, | ||
4017 | MHD_HTTP_HEADER_CONTENT_LENGTH, | ||
4018 | MHD_STATICSTR_LEN_ ( \ | ||
4019 | MHD_HTTP_HEADER_CONTENT_LENGTH), | ||
4020 | NULL, | ||
4021 | NULL)) | ||
4022 | { | ||
4023 | /* TODO: add individual settings */ | ||
4024 | if (1 <= connection->daemon->strict_for_client) | ||
4025 | { | ||
4026 | transmit_error_response_static (connection, | ||
4027 | MHD_HTTP_BAD_REQUEST, | ||
4028 | REQUEST_LENGTH_WITH_TR_ENCODING); | ||
4029 | return; | ||
4030 | } | ||
4031 | #ifdef HAVE_MESSAGES | ||
4032 | else | ||
4033 | { | ||
4034 | MHD_DLOG (connection->daemon, | ||
4035 | _ ("The 'Content-Length' request header is ignored " | ||
4036 | "as chunked Transfer-Encoding is used " | ||
4037 | "for this request.\n")); | ||
4038 | } | ||
4039 | #endif /* HAVE_MESSAGES */ | ||
4040 | } | ||
3999 | connection->rq.have_chunked_upload = true; | 4041 | connection->rq.have_chunked_upload = true; |
4000 | connection->rq.remaining_upload_size = MHD_SIZE_UNKNOWN; | 4042 | connection->rq.remaining_upload_size = MHD_SIZE_UNKNOWN; |
4001 | } | 4043 | } |