From fcaa181fb1c2c24309f52636e18e78e83e2662fd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A9ter=20Dimitrov?=
Date: Tue, 5 Sep 2017 11:33:16 +0200
Subject: inets: prepare for release
---
lib/inets/src/inets_app/inets.appup.src | 4 ----
lib/inets/vsn.mk | 2 +-
2 files changed, 1 insertion(+), 5 deletions(-)
(limited to 'lib')
diff --git a/lib/inets/src/inets_app/inets.appup.src b/lib/inets/src/inets_app/inets.appup.src
index f9ad8709d9..a86413147c 100644
--- a/lib/inets/src/inets_app/inets.appup.src
+++ b/lib/inets/src/inets_app/inets.appup.src
@@ -18,14 +18,10 @@
%% %CopyrightEnd%
{"%VSN%",
[
- {<<"6.2.4">>, [{load_module, httpd_request_handler,
- soft_purge, soft_purge, []}]},
{<<"6\\..*">>,[{restart_application, inets}]},
{<<"5\\..*">>,[{restart_application, inets}]}
],
[
- {<<"6.2.4">>, [{load_module, httpd_request_handler,
- soft_purge, soft_purge, []}]},
{<<"6\\..*">>,[{restart_application, inets}]},
{<<"5\\..*">>,[{restart_application, inets}]}
]
diff --git a/lib/inets/vsn.mk b/lib/inets/vsn.mk
index 96796f11c0..c4314f1ab5 100644
--- a/lib/inets/vsn.mk
+++ b/lib/inets/vsn.mk
@@ -19,6 +19,6 @@
# %CopyrightEnd%
APPLICATION = inets
-INETS_VSN = 6.4
+INETS_VSN = 6.4.1
PRE_VSN =
APP_VSN = "$(APPLICATION)-$(INETS_VSN)$(PRE_VSN)"
--
cgit v1.2.3
From 2a42a7d14bfdfdc323fa0b6da465f79821dafcae Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A9ter=20Dimitrov?=
Date: Tue, 5 Sep 2017 09:30:37 +0200
Subject: inets: Restore old behavior when parsing "+"
"+" is part of sub-delims according to RFC 3986 and shall not be
converted to space.
---
lib/inets/src/http_lib/http_uri.erl | 4 ----
lib/inets/test/uri_SUITE.erl | 4 ++--
2 files changed, 2 insertions(+), 6 deletions(-)
(limited to 'lib')
diff --git a/lib/inets/src/http_lib/http_uri.erl b/lib/inets/src/http_lib/http_uri.erl
index c4be5abd7c..7f1ca02014 100644
--- a/lib/inets/src/http_lib/http_uri.erl
+++ b/lib/inets/src/http_lib/http_uri.erl
@@ -117,8 +117,6 @@ decode(String) when is_list(String) ->
decode(String) when is_binary(String) ->
do_decode_binary(String).
-do_decode([$+|Rest]) ->
- [$ |do_decode(Rest)];
do_decode([$%,Hex1,Hex2|Rest]) ->
[hex2dec(Hex1)*16+hex2dec(Hex2)|do_decode(Rest)];
do_decode([First|Rest]) ->
@@ -126,8 +124,6 @@ do_decode([First|Rest]) ->
do_decode([]) ->
[].
-do_decode_binary(<<$+, Rest/bits>>) ->
- <<$ , (do_decode_binary(Rest))/binary>>;
do_decode_binary(<<$%, Hex:2/binary, Rest/bits>>) ->
<<(binary_to_integer(Hex, 16)), (do_decode_binary(Rest))/binary>>;
do_decode_binary(<>) ->
diff --git a/lib/inets/test/uri_SUITE.erl b/lib/inets/test/uri_SUITE.erl
index 3e7799141c..f973296af6 100644
--- a/lib/inets/test/uri_SUITE.erl
+++ b/lib/inets/test/uri_SUITE.erl
@@ -277,8 +277,8 @@ encode_decode(Config) when is_list(Config) ->
?assertEqual("foo%20bar", http_uri:encode("foo bar")),
?assertEqual(<<"foo%20bar">>, http_uri:encode(<<"foo bar">>)),
- ?assertEqual("foo bar", http_uri:decode("foo+bar")),
- ?assertEqual(<<"foo bar">>, http_uri:decode(<<"foo+bar">>)),
+ ?assertEqual("foo+bar", http_uri:decode("foo+bar")),
+ ?assertEqual(<<"foo+bar">>, http_uri:decode(<<"foo+bar">>)),
?assertEqual("foo bar", http_uri:decode("foo%20bar")),
?assertEqual(<<"foo bar">>, http_uri:decode(<<"foo%20bar">>)),
?assertEqual("foo\r\n", http_uri:decode("foo%0D%0A")),
--
cgit v1.2.3
From 5d01c70ca399edf28e99dc760506329689fab6ba Mon Sep 17 00:00:00 2001
From: Ingela Anderton Andin
Date: Thu, 1 Jun 2017 16:09:11 +0200
Subject: inets: httpd - Add chunk handling of client data
If the client uses PUT or POST to send a HTTP body the server
currently will gather the whole body in memory before passing it on to
the mod-callback. For legacy reasons it also converts the binary body
to a list, this is really bad for memory usage!
Add new option max_client_body_chunk to enable chunked handling of
content-length requests. Also make it possible for chunked-encoded data
to be propagated in portions to the mod-callback.
Conflicts:
lib/inets/test/httpd_SUITE.erl
---
lib/inets/doc/src/httpd.xml | 13 +-
lib/inets/doc/src/mod_esi.xml | 69 ++++++---
lib/inets/src/http_server/httpd_example.erl | 24 ++-
lib/inets/src/http_server/httpd_request.erl | 48 +++++-
.../src/http_server/httpd_request_handler.erl | 162 +++++++++++++++++----
lib/inets/src/http_server/httpd_response.erl | 24 ++-
lib/inets/src/http_server/mod_esi.erl | 40 ++---
lib/inets/test/httpd_SUITE.erl | 56 ++++++-
8 files changed, 329 insertions(+), 107 deletions(-)
(limited to 'lib')
diff --git a/lib/inets/doc/src/httpd.xml b/lib/inets/doc/src/httpd.xml
index d74635fc01..edf8731a82 100644
--- a/lib/inets/doc/src/httpd.xml
+++ b/lib/inets/doc/src/httpd.xml
@@ -279,7 +279,18 @@
requests defined by max_keep_alive_requests, the server
closes the connection. The server closes it even if there are
queued request. Default is no limit.
-
+
+
+
+ {max_client_body_chunk, integer()}
+ -
+
Enforces chunking of a HTTP PUT or POST body data to be deliverd
+ to the mod_esi callback. Note this is not supported for mod_cgi.
+ Default is no limit e.i the whole body is deliverd as one entity, which could
+ be very memory consuming. mod_esi(3).
+
+
+
diff --git a/lib/inets/doc/src/mod_esi.xml b/lib/inets/doc/src/mod_esi.xml
index 46cc796c8a..e2f0758cdf 100644
--- a/lib/inets/doc/src/mod_esi.xml
+++ b/lib/inets/doc/src/mod_esi.xml
@@ -121,35 +121,61 @@
- Module:Function(SessionID, Env, Input)-> _
+ Module:Function(SessionID, Env, Input)-> {continue, State} | _
Creates a dynamic web page and returns it chunk by chunk
to the server process by calling mod_esi:deliver/2.
SessionID = term()
Env = env()
- Input = string()
+ Input = string() | chunked_data()
+ chunked_data() = {first, Data::binary()} |
+ {continue, Data::binary(), State::term()} |
+ {last, Data::binary(), State::term()}
+ State = term()
Module must be found in the code path and export
Function with an arity of three. An erlScriptAlias must
also be set up in the configuration file for the web server.
- If the HTTP request is a 'post' request and a body is sent,
- content_length is the length of the posted
- data. If 'get' is used, query_string is the data after
- ? in the URL.
- ParsedHeader is the HTTP request as a key-value tuple
- list. The keys in ParsedHeader are in lower case.
- SessionID is an identifier
- the server uses when deliver/2 is called. Do not
- assume anything about the datatype.
- Use this callback function to generate dynamic web
- content dynamically. When a part of the page is generated, send the
- data back to the client through deliver/2. Notice
- that the first chunk of data sent to the client must at
- least contain all HTTP header fields that the response
- will generate. If the first chunk does not contain the
- end of HTTP header, that is, "\r\n\r\n",
- the server assumes that no HTTP header fields will be generated.
+
+ mod_esi:deliver/2 shall be used to generate the response
+ to the client and SessionID is an identifier that shall by used when
+ calling this function, do not assume anything about
+ the datatype. This function may be called
+ several times to chunk the the respons data. Notice that the
+ first chunk of data sent to the client must at least contain
+ all HTTP header fields that the response will generate. If the
+ first chunk does not contain the end of HTTP header,
+ that is, "\r\n\r\n", the server assumes that no HTTP
+ header fields will be generated.
+
+ Env environment data of the request see description above.
+
+ Input is query data of a GET request or the body of
+ a PUT or POST request. The default behavior (legacy reasons)
+ for delivering the body, is that the whole body is gathered and
+ converted to a string. But if the httpd config parameter
+ max_client_body_chunk
+ is set, the body will be delivered as binary chunks
+ instead. The maximum size of the chunks is either max_client_body_chunk
+ or decide by the client if it uses HTTP chunked encoding
+ to send the body. When using the chunking
+ mechanism this callback must return {continue, State::term()}
+ for all calls where Input is {first,
+ Data::binary()} or {continue, Data::binary(),
+ State::term()}. When Input is {last,
+ Data::binary(), State::term()} the return value will be ignored.
+ Note that if the body is
+ small all data may be delivered in only one chunk and then the
+ callback will be called with {last, Data::binary(), undefined}
+ without getting called with {first,
+ Data::binary()}.
The input State is
+ the last returned State, in it the callback can include
+ any data that it needs to keep track of when handling the chunks.
+
+
@@ -159,14 +185,13 @@
This function is deprecated and is only kept for backwards compatibility.
Env = env()
- Input = string()
+ Input = string()
Response = string()
This callback format consumes much memory, as the
whole response must be generated before it is sent to the
- user. This function is deprecated and is only kept for backwards
- compatibility.
+ user. This callback format is deprecated.
For new development, use Module:Function/3.
diff --git a/lib/inets/src/http_server/httpd_example.erl b/lib/inets/src/http_server/httpd_example.erl
index c893b10dca..45b6deba97 100644
--- a/lib/inets/src/http_server/httpd_example.erl
+++ b/lib/inets/src/http_server/httpd_example.erl
@@ -22,7 +22,7 @@
-export([print/1]).
-export([get/2, put/2, post/2, yahoo/2, test1/2, get_bin/2, peer/2]).
--export([newformat/3]).
+-export([newformat/3, post_chunked/3]).
%% These are used by the inets test-suite
-export([delay/1, chunk_timeout/3]).
@@ -131,15 +131,31 @@ footer() ->
"