diff options
author | Filipe David Manana <[email protected]> | 2010-09-26 11:58:45 +0100 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2010-10-05 15:08:23 +0200 |
commit | f9ec3cbca0f05fd9640bbd5cd3e21942c4512d3d (patch) | |
tree | 0b71168e700abdd029136dbadb3b6b2c89b97d71 /lib/orber/src/orber.erl | |
parent | 0a1f48c46cf629af7d3719e94250733d1589efa1 (diff) | |
download | otp-f9ec3cbca0f05fd9640bbd5cd3e21942c4512d3d.tar.gz otp-f9ec3cbca0f05fd9640bbd5cd3e21942c4512d3d.tar.bz2 otp-f9ec3cbca0f05fd9640bbd5cd3e21942c4512d3d.zip |
httpc: allow streaming of PUT and POST request bodies
This is a must when uploading large bodies that are to large to store
in a string or binary.
Besides a string or binary, a body can now be a function and
an accumulator.
Example:
-module(httpc_post_stream_test).
-compile(export_all).
-define(LEN, 1024 * 1024).
prepare_data() ->
{ok, Fd} = file:open("test_data.dat", [binary, write]),
ok = file:write(Fd, lists:duplicate(?LEN, "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,
{ok, {{_,200,_}, _, _}} = httpc:request(post, {"http://localhost:8888",
[{"content-length", integer_to_list(?LEN)}], "text/plain", {BodyFun, Fd1}}, [], []),
ok = file:close(Fd1).
Diffstat (limited to 'lib/orber/src/orber.erl')
0 files changed, 0 insertions, 0 deletions