aboutsummaryrefslogtreecommitdiffstats
path: root/lib/inets/doc
diff options
context:
space:
mode:
authorFilipe David Manana <[email protected]>2010-10-05 00:26:33 +0100
committerBjörn Gustavsson <[email protected]>2010-10-13 14:51:13 +0200
commit6951ed1075b8c36d5b6f51e5e5df7bd14602c1d8 (patch)
tree4ca1206c9a3b3f15465fd9f3f82f89c75a6ab577 /lib/inets/doc
parentf9ec3cbca0f05fd9640bbd5cd3e21942c4512d3d (diff)
downloadotp-6951ed1075b8c36d5b6f51e5e5df7bd14602c1d8.tar.gz
otp-6951ed1075b8c36d5b6f51e5e5df7bd14602c1d8.tar.bz2
otp-6951ed1075b8c36d5b6f51e5e5df7bd14602c1d8.zip
httpc: add option to do automatic chunked transfer-encoding
This is specially useful when a client doesn't know in advance the length of the payload (so that it can't set the Content-Length header). Example: -module(httpc_post_stream_test). -compile(export_all). prepare_data() -> crypto:start(), {ok, Fd} = file:open("test_data.dat", [binary, write]), ok = file:write(Fd, lists:duplicate(crypto:rand_uniform(8182, 32768), "1")), ok = file:close(Fd). test() -> inets:start(), ok = prepare_data(), {ok, Fd1} = file:open("test_data.dat", [binary, read]), BodyFun = fun(Fd) -> case file:read(Fd, 512) of eof -> eof; {ok, Data} -> {ok, Data, Fd} end end, %% header 'Transfer-Encoding: chunked' is added by httpc {ok, {{_,200,_}, _, _}} = httpc:request(post, {"http://localhost:8888", [], "text/plain", {chunkify, BodyFun, Fd1}}, [], []), ok = file:close(Fd1).
Diffstat (limited to 'lib/inets/doc')
-rw-r--r--lib/inets/doc/src/httpc.xml4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/inets/doc/src/httpc.xml b/lib/inets/doc/src/httpc.xml
index df333074cd..8b04b4c7f3 100644
--- a/lib/inets/doc/src/httpc.xml
+++ b/lib/inets/doc/src/httpc.xml
@@ -89,7 +89,9 @@ headers() = [header()]
header() = {field(), value()}
field() = string()
value() = string()
-body() = string() | binary() | {fun(acc()) -> send_fun_result(), acc()}
+body() = string() | binary() |
+ {fun(acc()) -> send_fun_result(), acc()} |
+ {chunkify, fun(acc()) -> send_fun_result(), acc()}
send_fun_result() = eof | {ok, iolist(), acc()}
acc() = term()
filename() = string()