erlang httpc

1,set proxy 10.100.1.76 :8888

 httpc:set_options([{proxy,{{"10.100.1.76",8888},[]}}]).

2,set cookie enabled

> httpc:set_options([{cookies,enabled}]).
ok

3,login and create team

 1 application:start(inets).
 2 httpc:set_options([{cookies,enabled}]).
 3 httpc:request("http://1.1.13.4/user/login").
 4 httpc:request(post,{"post url --remember add v2",[],"application/x-www-form-urlencoded", lists:concat(["post string curl use -d"])},[],[]).
 5 httpc:request(post,{"post url",[],"application/x-www-form-urlencoded", lists:concat(["post string curl use -d "])},[],[]).
 6 
 7 httpc:which_cookies(). 
 8 [{session_cookies,[{http_cookie,"1.1.13.4",true,
 9                                 "JSESSIONID","aaa6JQwGALt04aTzzID1u",undefined,session,"/",
10                                 false,false,"0"},
11                    {http_cookie,"1.1.13.4",true,"X-XX-SESS-ID",   %% u know what XX is
12                                 "f9vl028l6seblbh7v9i03ico02",undefined,session,"/",false,
13                                 false,"0"},
14                    {http_cookie,"1.1.13.4",true,"language","zh",undefined,
15                                 session,"/",false,false,"0"}]}]

4,e.z test case

 1 File Edit Options Buffers Tools Help
 2 -module(tt).
 3 -export([max/1]).
 4 
 5 
 6 max(N)->
 7 Max=erlang:system_info(process_limit),
 8 io:format("Maximum allowd processes:~p~n",[Max]),
 9 statistics(runtime),
10 statistics(wall_clock),
11 L=for(1,N,fun()-> spawn(fun()->wait() end) end),
12 {_,Time1}=statistics(runtime),
13 {_,Time2}=statistics(wall_clock),
14 lists:foreach(fun(Pid)->Pid ! die end, L),
15 U1=Time1 * 1000 / N ,
16 U2=Time2 * 1000 / N ,
17 io:format("Process spawn time=~p(~p) microseconds~n",
18 [U1,U2]).
19 
20 
21 wait()->
22         receive
23                 die -> httpc:request("http://192.168.1.51")
24         end.
25 for(N,N,F)->[F()];
26 for(I,N,F)->[F()|for(I+1,N,F)].
原文地址:https://www.cnblogs.com/eiguleo/p/4465629.html