diff options
author | CA Meijer <[email protected]> | 2013-03-02 06:48:04 +0200 |
---|---|---|
committer | Ingela Anderton Andin <[email protected]> | 2014-02-05 10:32:28 +0100 |
commit | 5e7c3147b25b96cf08c3083cbb32f18f955f6f0f (patch) | |
tree | 581dc9b9be0ca879589ec6cc3a48102010507a10 /lib/inets/test/http_format_SUITE.erl | |
parent | 3ec3fcf098df6d0c2895eb11eaeb45d041cbf605 (diff) | |
download | otp-5e7c3147b25b96cf08c3083cbb32f18f955f6f0f.tar.gz otp-5e7c3147b25b96cf08c3083cbb32f18f955f6f0f.tar.bz2 otp-5e7c3147b25b96cf08c3083cbb32f18f955f6f0f.zip |
Fix http_request:http_headers/1 to send content-length when length is zero
In R16B01, the http_request:http_headers/1 function removes the content-length
field from the HTTP headers if the content length is zero. This results in
some (perhaps many) HTTP servers rejecting POSTs and PUTs without data with
a 411 status word. From RFC2616, section 14.13: "Any Content-Length greater than
or EQUAL to zero is a valid value".
Diffstat (limited to 'lib/inets/test/http_format_SUITE.erl')
-rw-r--r-- | lib/inets/test/http_format_SUITE.erl | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/lib/inets/test/http_format_SUITE.erl b/lib/inets/test/http_format_SUITE.erl index 04c7358715..c913964094 100644 --- a/lib/inets/test/http_format_SUITE.erl +++ b/lib/inets/test/http_format_SUITE.erl @@ -35,14 +35,15 @@ chunk_decode_trailer/1, http_response/1, http_request/1, validate_request_line/1, esi_parse_headers/1, cgi_parse_headers/1, - is_absolut_uri/1, convert_netscapecookie_date/1]). + is_absolut_uri/1, convert_netscapecookie_date/1, + check_content_length_encoding/1]). suite() -> [{ct_hooks,[ts_install_cth]}]. all() -> [{group, chunk}, http_response, http_request, validate_request_line, {group, script}, is_absolut_uri, - convert_netscapecookie_date]. + convert_netscapecookie_date, check_content_length_encoding]. groups() -> [{script, [], [esi_parse_headers, cgi_parse_headers]}, @@ -456,6 +457,25 @@ validate_request_line(Config) when is_list(Config) -> httpd_request:validate("GET", NewForbiddenUri1, "HTTP/1.1"), ok. + +%%------------------------------------------------------------------------- +check_content_length_encoding(doc) -> + ["Test http_request:headers/2. Check that the content-length is" + " encoded even when it is zero." ]; +check_content_length_encoding(suite) -> + []; +check_content_length_encoding(Config) when is_list(Config) -> + + %% Check that the content-length is preserved. + %% Sanity check. + Header1 = http_request:http_headers(#http_request_h{'content-length'="123"}), + true = (string:str(Header1, "content-length: 123\r\n") > 0), + %% Check that content-length=0 is handled correctly. + Header2 = http_request:http_headers(#http_request_h{'content-length'="0"}), + true = (string:str(Header2, "content-length: 0\r\n") > 0), + + ok. + %%------------------------------------------------------------------------- esi_parse_headers(doc) -> ["Test httpd_esi:*. All header values are received in the same" |