diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c index 9c581f03..b25ee2a9 100644 --- a/src/microhttpd/connection.c +++ b/src/microhttpd/connection.c @@ -85,11 +85,11 @@ */ #ifdef HAVE_MESSAGES #define ERR_MSG_REQUEST_TOO_BIG \ - "" \ - "Request too big" \ - "Request HTTP header is too big for the memory constraints " \ - "of this webserver." \ - "" + "" \ + "Request too big" \ + "Request HTTP header is too big for the memory constraints " \ + "of this webserver." \ + "" #else #define ERR_MSG_REQUEST_TOO_BIG "" #endif @@ -99,14 +99,14 @@ */ #ifdef HAVE_MESSAGES #define ERR_MSG_REQUEST_HEADER_TOO_BIG \ - "" \ - "Request too big" \ - "

The total size of the request headers, which includes the " \ - "request target and the request field lines, exceeds the memory " \ - "constraints of this web server.

" \ - "

The request could be re-tried with shorter field lines, a shorter " \ - "request target or a shorter request method token.

" \ - "" + "" \ + "Request too big" \ + "

The total size of the request headers, which includes the " \ + "request target and the request field lines, exceeds the memory " \ + "constraints of this web server.

" \ + "

The request could be re-tried with shorter field lines, a shorter " \ + "request target or a shorter request method token.

" \ + "" #else #define ERR_MSG_REQUEST_HEADER_TOO_BIG "" #endif @@ -116,15 +116,15 @@ */ #ifdef HAVE_MESSAGES #define ERR_MSG_REQUEST_HEADER_WITH_COOKIES_TOO_BIG \ - "" \ - "Request too big" \ - "

The total size of the request headers, which includes the " \ - "request target and the request field lines, exceeds the memory " \ - "constraints of this web server.

" \ - "

The request could be re-tried with smaller " \ - ""Cookie:" field value, shorter other field lines, " \ - "a shorter request target or a shorter request method token.

" \ - "" + "" \ + "Request too big" \ + "

The total size of the request headers, which includes the " \ + "request target and the request field lines, exceeds the memory " \ + "constraints of this web server.

" \ + "

The request could be re-tried with smaller " \ + ""Cookie:" field value, shorter other field lines, " \ + "a shorter request target or a shorter request method token.

" \ + "" #else #define ERR_MSG_REQUEST_HEADER_WITH_COOKIES_TOO_BIG "" #endif @@ -135,15 +135,15 @@ */ #ifdef HAVE_MESSAGES #define ERR_MSG_REQUEST_CHUNK_LINE_EXT_TOO_BIG \ - "" \ - "Request too big" \ - "

The total size of the request target, the request field lines " \ - "and the chunk size line exceeds the memory constraints of this web " \ - "server.

" \ - "

The request could be re-tried without chunk extensions, with a smaller " \ - "chunk size, shorter field lines, a shorter request target or a shorter " \ - "request method token.

" \ - "" + "" \ + "Request too big" \ + "

The total size of the request target, the request field lines " \ + "and the chunk size line exceeds the memory constraints of this web " \ + "server.

" \ + "

The request could be re-tried without chunk extensions, with a smaller " \ + "chunk size, shorter field lines, a shorter request target or a shorter " \ + "request method token.

" \ + "" #else #define ERR_MSG_REQUEST_CHUNK_LINE_EXT_TOO_BIG "" #endif @@ -154,15 +154,15 @@ */ #ifdef HAVE_MESSAGES #define ERR_MSG_REQUEST_CHUNK_LINE_TOO_BIG \ - "" \ - "Request too big" \ - "

The total size of the request target, the request field lines " \ - "and the chunk size line exceeds the memory constraints of this web " \ - "server.

" \ - "

The request could be re-tried with a smaller " \ - "chunk size, shorter field lines, a shorter request target or a shorter " \ - "request method token.

" \ - "" + "" \ + "Request too big" \ + "

The total size of the request target, the request field lines " \ + "and the chunk size line exceeds the memory constraints of this web " \ + "server.

" \ + "

The request could be re-tried with a smaller " \ + "chunk size, shorter field lines, a shorter request target or a shorter " \ + "request method token.

" \ + "" #else #define ERR_MSG_REQUEST_CHUNK_LINE_TOO_BIG "" #endif @@ -172,15 +172,15 @@ */ #ifdef HAVE_MESSAGES #define ERR_MSG_REQUEST_FOOTER_TOO_BIG \ - "" \ - "Request too big" \ - "

The total size of the request headers, which includes the " \ - "request target, the request field lines and the chunked trailer " \ - "section exceeds the memory constraints of this web server.

" \ - "

The request could be re-tried with a shorter chunked trailer " \ - "section, shorter field lines, a shorter request target or " \ - "a shorter request method token.

" \ - "" + "" \ + "Request too big" \ + "

The total size of the request headers, which includes the " \ + "request target, the request field lines and the chunked trailer " \ + "section exceeds the memory constraints of this web server.

" \ + "

The request could be re-tried with a shorter chunked trailer " \ + "section, shorter field lines, a shorter request target or " \ + "a shorter request method token.

" \ + "" #else #define ERR_MSG_REQUEST_FOOTER_TOO_BIG "" #endif @@ -190,10 +190,10 @@ */ #ifdef HAVE_MESSAGES #define RQ_LINE_TOO_MANY_WSP \ - "" \ - "Request broken" \ - "The request line has more then two whitespaces." \ - "" + "" \ + "Request broken" \ + "The request line has more then two whitespaces." \ + "" #else #define RQ_LINE_TOO_MANY_WSP "" #endif @@ -204,11 +204,11 @@ */ #ifdef HAVE_MESSAGES #define BARE_CR_IN_HEADER \ - "" \ - "Request broken" \ - "Request HTTP header has bare CR character without " \ - "following LF character." \ - "" + "" \ + "Request broken" \ + "Request HTTP header has bare CR character without " \ + "following LF character." \ + "" #else #define BARE_CR_IN_HEADER "" #endif @@ -219,11 +219,11 @@ */ #ifdef HAVE_MESSAGES #define BARE_CR_IN_FOOTER \ - "" \ - "Request broken" \ - "Request HTTP footer has bare CR character without " \ - "following LF character." \ - "" + "" \ + "Request broken" \ + "Request HTTP footer has bare CR character without " \ + "following LF character." \ + "" #else #define BARE_CR_IN_FOOTER "" #endif @@ -234,11 +234,11 @@ */ #ifdef HAVE_MESSAGES #define BARE_LF_IN_HEADER \ - "" \ - "Request broken" \ - "Request HTTP header has bare LF character without " \ - "preceding CR character." \ - "" + "" \ + "Request broken" \ + "Request HTTP header has bare LF character without " \ + "preceding CR character." \ + "" #else #define BARE_LF_IN_HEADER "" #endif @@ -249,11 +249,11 @@ */ #ifdef HAVE_MESSAGES #define BARE_LF_IN_FOOTER \ - "" \ - "Request broken" \ - "Request HTTP footer has bare LF character without " \ - "preceding CR character." \ - "" + "" \ + "Request broken" \ + "Request HTTP footer has bare LF character without " \ + "preceding CR character." \ + "" #else #define BARE_LF_IN_FOOTER "" #endif @@ -263,11 +263,11 @@ */ #ifdef HAVE_MESSAGES #define RQ_TARGET_INVALID_CHAR \ - "" \ - "Request broken" \ - "HTTP request has invalid characters in " \ - "the request-target." \ - "" + "" \ + "Request broken" \ + "HTTP request has invalid characters in " \ + "the request-target." \ + "" #else #define RQ_TARGET_INVALID_CHAR "" #endif @@ -277,10 +277,10 @@ */ #ifdef HAVE_MESSAGES #define ERR_RSP_OBS_FOLD \ - "" \ - "Request broken" \ - "Obsolete line folding is used in HTTP request header." \ - "" + "" \ + "Request broken" \ + "Obsolete line folding is used in HTTP request header." \ + "" #else #define ERR_RSP_OBS_FOLD "" #endif @@ -290,10 +290,10 @@ */ #ifdef HAVE_MESSAGES #define ERR_RSP_OBS_FOLD_FOOTER \ - "" \ - "Request broken" \ - "Obsolete line folding is used in HTTP request footer." \ - "" + "" \ + "Request broken" \ + "Obsolete line folding is used in HTTP request footer." \ + "" #else #define ERR_RSP_OBS_FOLD_FOOTER "" #endif @@ -304,11 +304,11 @@ */ #ifdef HAVE_MESSAGES #define ERR_RSP_WSP_BEFORE_HEADER \ - "" \ - "Request broken" \ - "HTTP request has whitespace between the request line and " \ - "the first header." \ - "" + "" \ + "Request broken" \ + "HTTP request has whitespace between the request line and " \ + "the first header." \ + "" #else #define ERR_RSP_WSP_BEFORE_HEADER "" #endif @@ -319,11 +319,11 @@ */ #ifdef HAVE_MESSAGES #define ERR_RSP_WSP_BEFORE_FOOTER \ - "" \ - "Request broken" \ - "First HTTP footer line has whitespace at the first " \ - "position." \ - "" + "" \ + "Request broken" \ + "First HTTP footer line has whitespace at the first " \ + "position." \ + "" #else #define ERR_RSP_WSP_BEFORE_FOOTER "" #endif @@ -334,11 +334,11 @@ */ #ifdef HAVE_MESSAGES #define ERR_RSP_WSP_IN_HEADER_NAME \ - "" \ - "Request broken" \ - "HTTP request has whitespace before the first colon " \ - "in header line." \ - "" + "" \ + "Request broken" \ + "HTTP request has whitespace before the first colon " \ + "in header line." \ + "" #else #define ERR_RSP_WSP_IN_HEADER_NAME "" #endif @@ -349,11 +349,11 @@ */ #ifdef HAVE_MESSAGES #define ERR_RSP_WSP_IN_FOOTER_NAME \ - "" \ - "Request broken" \ - "HTTP request has whitespace before the first colon " \ - "in footer line." \ - "" + "" \ + "Request broken" \ + "HTTP request has whitespace before the first colon " \ + "in footer line." \ + "" #else #define ERR_RSP_WSP_IN_FOOTER_NAME "" #endif @@ -365,10 +365,10 @@ */ #ifdef HAVE_MESSAGES #define ERR_RSP_INVALID_CHAR_IN_FIELD_NAME \ - "" \ - "Request broken" \ - "HTTP request has invalid character in field name." \ - "" + "" \ + "Request broken" \ + "HTTP request has invalid character in field name." \ + "" #else #define ERR_RSP_INVALID_CHAR_IN_FIELD_NAME "" #endif @@ -378,10 +378,10 @@ */ #ifdef HAVE_MESSAGES #define ERR_RSP_INVALID_CHR_IN_HEADER \ - "" \ - "Request broken" \ - "HTTP request has invalid character in header." \ - "" + "" \ + "Request broken" \ + "HTTP request has invalid character in header." \ + "" #else #define ERR_RSP_INVALID_CHR_IN_HEADER "" #endif @@ -391,10 +391,10 @@ */ #ifdef HAVE_MESSAGES #define ERR_RSP_INVALID_CHR_IN_FOOTER \ - "" \ - "Request broken" \ - "HTTP request has invalid character in footer." \ - "" + "" \ + "Request broken" \ + "HTTP request has invalid character in footer." \ + "" #else #define ERR_RSP_INVALID_CHR_IN_FOOTER "" #endif @@ -404,10 +404,10 @@ */ #ifdef HAVE_MESSAGES #define ERR_RSP_HEADER_WITHOUT_COLON \ - "" \ - "Request broken" \ - "HTTP request header line has no colon character." \ - "" + "" \ + "Request broken" \ + "HTTP request header line has no colon character." \ + "" #else #define ERR_RSP_HEADER_WITHOUT_COLON "" #endif @@ -417,10 +417,10 @@ */ #ifdef HAVE_MESSAGES #define ERR_RSP_FOOTER_WITHOUT_COLON \ - "" \ - "Request broken" \ - "HTTP request footer line has no colon character." \ - "" + "" \ + "Request broken" \ + "HTTP request footer line has no colon character." \ + "" #else #define ERR_RSP_FOOTER_WITHOUT_COLON "" #endif @@ -430,10 +430,10 @@ */ #ifdef HAVE_MESSAGES #define ERR_RSP_EMPTY_HEADER_NAME \ - "" \ - "Request broken" \ - "HTTP request header has empty header name." \ - "" + "" \ + "Request broken" \ + "HTTP request header has empty header name." \ + "" #else #define ERR_RSP_EMPTY_HEADER_NAME "" #endif @@ -443,10 +443,10 @@ */ #ifdef HAVE_MESSAGES #define ERR_RSP_EMPTY_FOOTER_NAME \ - "" \ - "Request broken" \ - "HTTP request footer has empty footer name." \ - "" + "" \ + "Request broken" \ + "HTTP request footer has empty footer name." \ + "" #else #define ERR_RSP_EMPTY_FOOTER_NAME "" #endif @@ -460,24 +460,40 @@ */ #ifdef HAVE_MESSAGES #define REQUEST_LACKS_HOST \ - "" \ - ""Host:" header required" \ - "HTTP/1.1 request without "Host:"." \ - "" + "" \ + ""Host:" header required" \ + "HTTP/1.1 request without "Host:"." \ + "" #else #define REQUEST_LACKS_HOST "" #endif + +/** + * Response text used when the request (http header) has + * multiple "Content-length" headers. + */ +#ifdef HAVE_MESSAGES +#define REQUEST_AMBIGUOUS_CONTENT_LENGTH \ + "" \ + ""Content-Length:" header must be unique" \ + "HTTP/1.1 request with multiple "Content-Length:" headers." \ + "" + +#else +#define REQUEST_AMBIGUOUS_CONTENT_LENGTH "" +#endif + /** * Response text used when the request has unsupported "Transfer-Encoding:". */ #ifdef HAVE_MESSAGES #define REQUEST_UNSUPPORTED_TR_ENCODING \ - "" \ - "Unsupported Transfer-Encoding" \ - "The Transfer-Encoding used in request is not supported." \ - "" + "" \ + "Unsupported Transfer-Encoding" \ + "The Transfer-Encoding used in request is not supported." \ + "" #else #define REQUEST_UNSUPPORTED_TR_ENCODING "" #endif @@ -488,11 +504,11 @@ */ #ifdef HAVE_MESSAGES #define REQUEST_LENGTH_WITH_TR_ENCODING \ - "" \ - "Malformed request" \ - "Wrong combination of the request headers: both Transfer-Encoding " \ - "and Content-Length headers are used at the same time." \ - "" + "" \ + "Malformed request" \ + "Wrong combination of the request headers: both Transfer-Encoding " \ + "and Content-Length headers are used at the same time." \ + "" #else #define REQUEST_LENGTH_WITH_TR_ENCODING "" #endif @@ -506,8 +522,8 @@ */ #ifdef HAVE_MESSAGES #define REQUEST_MALFORMED \ - "Request malformed" \ - "HTTP request is syntactically incorrect." + "Request malformed" \ + "HTTP request is syntactically incorrect." #else #define REQUEST_MALFORMED "" #endif @@ -516,8 +532,8 @@ * Response text used when the request target path has %00 sequence. */ #define REQUEST_HAS_NUL_CHAR_IN_PATH \ - "Bad Request Path" \ - "The request path contains invalid characters." + "Bad Request Path" \ + "The request path contains invalid characters." /** * Response text used when the request HTTP chunked encoding is @@ -525,8 +541,8 @@ */ #ifdef HAVE_MESSAGES #define REQUEST_CHUNKED_MALFORMED \ - "Request malformed" \ - "HTTP chunked encoding is syntactically incorrect." + "Request malformed" \ + "HTTP chunked encoding is syntactically incorrect." #else #define REQUEST_CHUNKED_MALFORMED "" #endif @@ -536,9 +552,9 @@ */ #ifdef HAVE_MESSAGES #define REQUEST_CHUNK_TOO_LARGE \ - "Request content too large" \ - "The chunk size used in HTTP chunked encoded " \ - "request is too large." + "Request content too large" \ + "The chunk size used in HTTP chunked encoded " \ + "request is too large." #else #define REQUEST_CHUNK_TOO_LARGE "" #endif @@ -548,9 +564,9 @@ */ #ifdef HAVE_MESSAGES #define REQUEST_CONTENTLENGTH_TOOLARGE \ - "Request content too large" \ - "HTTP request has too large value for " \ - "Content-Length header." + "Request content too large" \ + "HTTP request has too large value for " \ + "Content-Length header." #else #define REQUEST_CONTENTLENGTH_TOOLARGE "" #endif @@ -561,9 +577,9 @@ */ #ifdef HAVE_MESSAGES #define REQUEST_CONTENTLENGTH_MALFORMED \ - "Request malformed" \ - "HTTP request has wrong value for " \ - "Content-Length header." + "Request malformed" \ + "HTTP request has wrong value for " \ + "Content-Length header." #else #define REQUEST_CONTENTLENGTH_MALFORMED "" #endif @@ -576,10 +592,10 @@ */ #ifdef HAVE_MESSAGES #define ERROR_MSG_DATA_NOT_HANDLED_BY_APP \ - "Internal server error" \ - "Please ask the developer of this Web server to carefully " \ - "read the GNU libmicrohttpd documentation about connection " \ - "management and blocking." + "Internal server error" \ + "Please ask the developer of this Web server to carefully " \ + "read the GNU libmicrohttpd documentation about connection " \ + "management and blocking." #else #define ERROR_MSG_DATA_NOT_HANDLED_BY_APP "" #endif @@ -589,9 +605,9 @@ */ #ifdef HAVE_MESSAGES #define REQ_HTTP_VER_IS_TOO_OLD \ - "Requested HTTP version is not supported" \ - "Requested HTTP version is too old and not " \ - "supported." + "Requested HTTP version is not supported" \ + "Requested HTTP version is too old and not " \ + "supported." #else #define REQ_HTTP_VER_IS_TOO_OLD "" #endif @@ -601,8 +617,8 @@ */ #ifdef HAVE_MESSAGES #define REQ_HTTP_VER_IS_NOT_SUPPORTED \ - "Requested HTTP version is not supported" \ - "Requested HTTP version is not supported." + "Requested HTTP version is not supported" \ + "Requested HTTP version is not supported." #else #define REQ_HTTP_VER_IS_NOT_SUPPORTED "" #endif @@ -1206,8 +1222,8 @@ MHD_lookup_header_token_ci (const struct MHD_Connection *connection, * false otherwise */ #define MHD_lookup_header_s_token_ci(c,h,tkn) \ - MHD_lookup_header_token_ci ((c),(h),MHD_STATICSTR_LEN_ (h), \ - (tkn),MHD_STATICSTR_LEN_ (tkn)) + MHD_lookup_header_token_ci ((c),(h),MHD_STATICSTR_LEN_ (h), \ + (tkn),MHD_STATICSTR_LEN_ (tkn)) /** @@ -2377,7 +2393,7 @@ buffer_append (char *buf, * false if not enough space is available */ #define buffer_append_s(buf,ppos,buf_size,str) \ - buffer_append (buf,ppos,buf_size,str, MHD_STATICSTR_LEN_ (str)) + buffer_append (buf,ppos,buf_size,str, MHD_STATICSTR_LEN_ (str)) /** @@ -2982,14 +2998,14 @@ transmit_error_response_len (struct MHD_Connection *connection, */ #ifdef HAVE_MESSAGES # define transmit_error_response_static(c, code, msg) \ - transmit_error_response_len (c, code, \ - msg, MHD_STATICSTR_LEN_ (msg), \ - NULL, 0, NULL, 0) + transmit_error_response_len (c, code, \ + msg, MHD_STATICSTR_LEN_ (msg), \ + NULL, 0, NULL, 0) #else /* ! HAVE_MESSAGES */ # define transmit_error_response_static(c, code, msg) \ - transmit_error_response_len (c, code, \ - "", 0, \ - NULL, 0, NULL, 0) + transmit_error_response_len (c, code, \ + "", 0, \ + NULL, 0, NULL, 0) #endif /* ! HAVE_MESSAGES */ /** @@ -2997,16 +3013,16 @@ transmit_error_response_len (struct MHD_Connection *connection, */ #ifdef HAVE_MESSAGES # define transmit_error_response_header(c, code, m, hd_n, hd_n_l, hd_v, hd_v_l) \ - transmit_error_response_len (c, code, \ - m, MHD_STATICSTR_LEN_ (m), \ - hd_n, hd_n_l, \ - hd_v, hd_v_l) + transmit_error_response_len (c, code, \ + m, MHD_STATICSTR_LEN_ (m), \ + hd_n, hd_n_l, \ + hd_v, hd_v_l) #else /* ! HAVE_MESSAGES */ # define transmit_error_response_header(c, code, m, hd_n, hd_n_l, hd_v, hd_v_l) \ - transmit_error_response_len (c, code, \ - "", 0, \ - hd_n, hd_n_l, \ - hd_v, hd_v_l) + transmit_error_response_len (c, code, \ + "", 0, \ + hd_n, hd_n_l, \ + hd_v, hd_v_l) #endif /* ! HAVE_MESSAGES */ @@ -4795,9 +4811,7 @@ check_write_done (struct MHD_Connection *connection, static void parse_connection_headers (struct MHD_Connection *connection) { - const char *clen; const char *enc; - size_t val_len; #ifdef COOKIE_SUPPORT if (MHD_PARSE_COOKIE_NO_MEMORY == parse_cookie_header (connection)) @@ -4849,14 +4863,14 @@ parse_connection_headers (struct MHD_Connection *connection) REQUEST_UNSUPPORTED_TR_ENCODING); return; } - else if (MHD_NO != - MHD_lookup_connection_value_n (connection, - MHD_HEADER_KIND, - MHD_HTTP_HEADER_CONTENT_LENGTH, - MHD_STATICSTR_LEN_ ( \ - MHD_HTTP_HEADER_CONTENT_LENGTH), - NULL, - NULL)) + if (MHD_NO != + MHD_lookup_connection_value_n (connection, + MHD_HEADER_KIND, + MHD_HTTP_HEADER_CONTENT_LENGTH, + MHD_STATICSTR_LEN_ ( \ + MHD_HTTP_HEADER_CONTENT_LENGTH), + NULL, + NULL)) { /* TODO: add individual settings */ if (1 <= connection->daemon->client_discipline) @@ -4881,50 +4895,71 @@ parse_connection_headers (struct MHD_Connection *connection) connection->rq.have_chunked_upload = true; connection->rq.remaining_upload_size = MHD_SIZE_UNKNOWN; } - else if (MHD_NO != - MHD_lookup_connection_value_n (connection, - MHD_HEADER_KIND, - MHD_HTTP_HEADER_CONTENT_LENGTH, - MHD_STATICSTR_LEN_ ( - MHD_HTTP_HEADER_CONTENT_LENGTH), - &clen, - &val_len)) + else /* was: transfer encoding set */ { - size_t num_digits; + bool found = false; + struct MHD_HTTP_Req_Header *pos; - num_digits = MHD_str_to_uint64_n_ (clen, - val_len, - &connection->rq.remaining_upload_size); + for (pos = connection->rq.headers_received; NULL != pos; pos = pos->next) + if ( (0 != (pos->kind & MHD_HEADER_KIND)) && + (MHD_str_equal_caseless_bin_n_ (MHD_HTTP_HEADER_CONTENT_LENGTH, + pos->header, + MHD_STATICSTR_LEN_ ( + MHD_HTTP_HEADER_CONTENT_LENGTH))) ) + { + const char *clen; + size_t val_len; + size_t num_digits; - if (((0 == num_digits) && - (0 != val_len) && - ('0' <= clen[0]) && ('9' >= clen[0])) - || (MHD_SIZE_UNKNOWN == connection->rq.remaining_upload_size)) - { - connection->rq.remaining_upload_size = 0; + if (found && + (1 <= connection->daemon->client_discipline)) + { + /* more than one header, bad */ + transmit_error_response_static (connection, + MHD_HTTP_BAD_REQUEST, + REQUEST_AMBIGUOUS_CONTENT_LENGTH); + return; + } + found = true; + val_len = pos->value_size; + clen = pos->value; + num_digits = MHD_str_to_uint64_n_ (clen, + val_len, + &connection->rq.remaining_upload_size + ); + + if (((0 == num_digits) && + (0 != val_len) && + ('0' <= clen[0]) && ('9' >= clen[0])) + || (MHD_SIZE_UNKNOWN == connection->rq.remaining_upload_size)) + { + connection->rq.remaining_upload_size = 0; #ifdef HAVE_MESSAGES - MHD_DLOG (connection->daemon, - _ ("Too large value of 'Content-Length' header. " \ - "Closing connection.\n")); + MHD_DLOG (connection->daemon, + _ ("Too large value of 'Content-Length' header. " \ + "Closing connection.\n")); #endif - transmit_error_response_static (connection, - MHD_HTTP_CONTENT_TOO_LARGE, - REQUEST_CONTENTLENGTH_TOOLARGE); - } - else if ((val_len != num_digits) || - (0 == num_digits)) - { - connection->rq.remaining_upload_size = 0; + transmit_error_response_static (connection, + MHD_HTTP_CONTENT_TOO_LARGE, + REQUEST_CONTENTLENGTH_TOOLARGE); + return; + } + if ( (val_len != num_digits) || + (0 == num_digits) ) + { + connection->rq.remaining_upload_size = 0; #ifdef HAVE_MESSAGES - MHD_DLOG (connection->daemon, - _ ("Failed to parse 'Content-Length' header. " \ - "Closing connection.\n")); + MHD_DLOG (connection->daemon, + _ ("Failed to parse 'Content-Length' header. " \ + "Closing connection.\n")); #endif - transmit_error_response_static (connection, - MHD_HTTP_BAD_REQUEST, - REQUEST_CONTENTLENGTH_MALFORMED); - } - } + transmit_error_response_static (connection, + MHD_HTTP_BAD_REQUEST, + REQUEST_CONTENTLENGTH_MALFORMED); + return; + } + } /* for all HTTP headers */ + } /* was: else: transfer encoding is not set */ }