diff options
author | Bernard Duggan <[email protected]> | 2011-02-23 15:55:37 +1100 |
---|---|---|
committer | Niclas Axelsson <[email protected]> | 2011-02-24 17:54:12 +0100 |
commit | 73f261d2f44a58fda92e3d6e035051c11c3e4521 (patch) | |
tree | 797de791e8bb05cbf20512a65a5ad102a1ac725b /lib/inets | |
parent | 7bc880298b2f0994f2902cb0290e4fd035b01865 (diff) | |
download | otp-73f261d2f44a58fda92e3d6e035051c11c3e4521.tar.gz otp-73f261d2f44a58fda92e3d6e035051c11c3e4521.tar.bz2 otp-73f261d2f44a58fda92e3d6e035051c11c3e4521.zip |
Modify mod_esi:deliver/2 to accept binary data
This change allows for more efficient delivery of large amounts of
data through the mod_esi interface when the handling process has that
data in binary format. It avoids the need to convert to list and the
extra memory involved in passing that list between processes.
Diffstat (limited to 'lib/inets')
-rw-r--r-- | lib/inets/doc/src/mod_esi.xml | 6 | ||||
-rw-r--r-- | lib/inets/src/http_server/mod_esi.erl | 4 |
2 files changed, 8 insertions, 2 deletions
diff --git a/lib/inets/doc/src/mod_esi.xml b/lib/inets/doc/src/mod_esi.xml index 3c473d3f94..e063088eb4 100644 --- a/lib/inets/doc/src/mod_esi.xml +++ b/lib/inets/doc/src/mod_esi.xml @@ -41,7 +41,7 @@ <fsummary>Sends Data back to client.</fsummary> <type> <v>SessionID = term()</v> - <v>Data = string() | io_list()</v> + <v>Data = string() | io_list() | binary()</v> <v>Reason = term()</v> </type> <desc> @@ -54,7 +54,9 @@ <note><p>Note that if any HTTP-header fields should be added by the script they must be in the first call to deliver/2 and the - data in the call must be a string. Do not + data in the call must be a string. Calls after the headers + are complete may contain binary data to reduce copying + overhead. Do not assume anything about the data type of SessionID, the SessionID must be the value given as input to the esi call back function that you implemented.</p></note> diff --git a/lib/inets/src/http_server/mod_esi.erl b/lib/inets/src/http_server/mod_esi.erl index 929185a67a..b85c479693 100644 --- a/lib/inets/src/http_server/mod_esi.erl +++ b/lib/inets/src/http_server/mod_esi.erl @@ -452,6 +452,10 @@ handle_body(Pid, ModData, Body, Timeout, Size, IsDisableChunkedSend) -> ?hdrt("handle_body - send chunk", [{timeout, Timeout}, {size, Size}]), httpd_response:send_chunk(ModData, Body, IsDisableChunkedSend), receive + {esi_data, Data} when is_binary(Data) -> + ?hdrt("handle_body - received binary data (esi)", []), + handle_body(Pid, ModData, Data, Timeout, Size + byte_size(Data), + IsDisableChunkedSend); {esi_data, Data} -> ?hdrt("handle_body - received data (esi)", []), handle_body(Pid, ModData, Data, Timeout, Size + length(Data), |