-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheHttpBenchStd.erl
More file actions
46 lines (34 loc) · 1 KB
/
eHttpBenchStd.erl
File metadata and controls
46 lines (34 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
-module(eHttpBenchStd).
-export([start/4,sendHttpGetRequest/1]).
start(URL,CNum,RNum,RemNum)->
inets:start(),
Pid= self(),
Request = buildRequestForHttpLib(URL),
eHttpBenchCommon:launchWorkers(Pid,Request, fun eHttpBenchStd:sendHttpGetRequest/1,
CNum,CNum,RNum,RemNum,[]),
eHttpBenchCommon:waitWorkersDone(Pid,CNum*RNum+RemNum).
buildRequestForHttpLib(URL)->
{get,
{
URL,
[
{"Connection","keep-alive"},
{"Accept", "*/*" },
{"User-Agent","eHttpBench std mode 1.0"}
]
},
[
{version,"HTTP/1.1"}
],
[]
}.
sendHttpGetRequest(Request)->
{Method, Req, HTTPOptions, Options} = Request,
Result = httpc:request(Method,Req,HTTPOptions,Options),
%io:format("Result:~p",[Result]),
case Result of
{ok, {{_, 200, _},_, _}} ->
ok;
_ ->
error
end.