inets提供ftp client,http client/server,tftp client/server
>inet:getiflist().
{ok,["lo0","en0"]}
>inet:ifget("en0", [mtu]).
{ok,[{
mtu,1500}]}
。httpc
-module(httpc_post_stream_test).
-compile(export_all).
-define(LEN, 1024 * 1024).
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,
{ok, {
{_,200,_}, _, _}} = httpc:request(post, {"http://localhost:8888",[], "text/plain", {
chunkify, BodyFun, Fd1}}, [], []),
ok = file:close(Fd1).
Url = "http://example.org",
httpc:request(get, {Url, [{"Cookie", "name1=value1;name2&#