diff --git a/.gitignore b/.gitignore index 1491146..3f362b6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,12 @@ -ebin/ -*~ -.eunit/ -*beam -doc/*.html -doc/*.css -doc/*.png -doc/edoc-info -Emakefile -*.bat -.dialyzer_plt +_build +ebin +*.beam +*.sw* +deps +.DS_Store +erl_crash.dump +.eunit +mime.types +.rebar +*.plt .rebar diff --git a/.travis.yml b/.travis.yml index 4b98f46..0861069 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,14 @@ language: erlang otp_release: - R16B -script: "make test" + - R16B03-1 + - 17.0 + - 17.1 + - 18.0 + - 18.1 +before_script: + - curl -X PUT localhost:5984/couchbeam_testdb + - curl -X PUT localhost:5984/couchbeam_testdb2 + - curl -X PUT localhost:5984/couchbeam_testdb3 + - "./bootstrap_travis.sh" +script: "./rebar3 eunit" diff --git a/Makefile b/Makefile index d2e61c6..918f33b 100644 --- a/Makefile +++ b/Makefile @@ -3,43 +3,31 @@ IBROWSE_VSN = $(shell sed -n 's/.*{vsn,.*"\(.*\)"}.*/\1/p' src/ibrowse.app.src) DIALYZER_PLT=$(CURDIR)/.dialyzer_plt DIALYZER_APPS=erts kernel stdlib ssl crypto public_key +REBAR ?= $(shell which rebar3) + all: compile compile: - ./rebar compile + $(REBAR) compile clean: - ./rebar clean - -install: compile - mkdir -p $(DESTDIR)/lib/ibrowse-$(IBROWSE_VSN)/ - cp -r ebin $(DESTDIR)/lib/ibrowse-$(IBROWSE_VSN)/ - -eunit_test: all - ./rebar eunit + $(REBAR) clean -test: all - cd test; erl -pa ../../ibrowse/ebin -make; cd ../; \ - erl -noshell -pa test -pa ebin -s ibrowse_test unit_tests \ - -s ibrowse_test verify_chunked_streaming \ - -s ibrowse_test test_chunked_streaming_once \ - -s erlang halt +test: + $(REBAR) eunit xref: all - ./rebar xref + $(REBAR) xref docs: - erl -noshell \ - -eval 'edoc:application(ibrowse, ".", []), init:stop().' - -$(DIALYZER_PLT): - @echo Creating dialyzer plt file: $(DIALYZER_PLT) - @echo This may take a minute or two... - @echo - dialyzer --output_plt $(DIALYZER_PLT) --build_plt \ - --apps $(DIALYZER_APPS) - -dialyzer: $(DIALYZER_PLT) - @echo Running dialyzer... - @echo - dialyzer --fullpath --plt $(DIALYZER_PLT) -Wrace_conditions -Wunmatched_returns -Werror_handling -r ./ebin + $(REBAR) edoc + +dialyzer: + $(REBAR) dialyzer + + +install: compile + mkdir -p $(DESTDIR)/lib/ibrowse-$(IBROWSE_VSN)/ + cp -r _build/lib/default/ibrowse/ebin $(DESTDIR)/lib/ibrowse-$(IBROWSE_VSN)/ + +.PHONY: test docs \ No newline at end of file diff --git a/bootstrap_travis.sh b/bootstrap_travis.sh new file mode 100755 index 0000000..a222df3 --- /dev/null +++ b/bootstrap_travis.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +curl -O -L https://s3.amazonaws.com/rebar3/rebar3 +chmod +x rebar3 +./rebar3 update \ No newline at end of file diff --git a/doc/edoc-info b/doc/edoc-info new file mode 100644 index 0000000..8d400b5 --- /dev/null +++ b/doc/edoc-info @@ -0,0 +1,4 @@ +%% encoding: UTF-8 +{application,ibrowse}. +{modules,[ibrowse,ibrowse_app,ibrowse_http_client,ibrowse_lb,ibrowse_lib, + ibrowse_socks5,ibrowse_sup]}. diff --git a/doc/erlang.png b/doc/erlang.png new file mode 100644 index 0000000..987a618 Binary files /dev/null and b/doc/erlang.png differ diff --git a/doc/ibrowse.html b/doc/ibrowse.html index 1594d74..e7c5afd 100644 --- a/doc/ibrowse.html +++ b/doc/ibrowse.html @@ -1,6 +1,7 @@ + Module ibrowse @@ -10,9 +11,8 @@

Module ibrowse

The ibrowse application implements an HTTP 1.1 client in erlang. -

Copyright © 2005-2010 Chandrashekhar Mullaparthi

+

Copyright © 2005-2014 Chandrashekhar Mullaparthi

-

Version: 2.1.2

Behaviours: gen_server.

Authors: Chandrashekhar Mullaparthi (chandrashekhar dot mullaparthi at gmail dot com).

@@ -61,10 +61,13 @@ send_req/4, send_req/5, send_req/6.

Function Index

- +
all_trace_off/0Turn Off ALL tracing.
+ + + @@ -85,19 +88,19 @@ send_req/4, send_req/5, send_req/6.

+ + - + - + @@ -118,9 +121,14 @@ send_req/4, send_req/5, send_req/6.

Function Details

+

add_config/1

+
+

add_config(Terms) -> any()

+

Add additional configuration elements at runtime.

+

all_trace_off/0

-

all_trace_off() -> ok

+

all_trace_off() -> ok

Turn Off ALL tracing

code_change/3

@@ -138,6 +146,16 @@ send_req/4, send_req/5, send_req/6.

get_config_value(Key, DefVal) -> any()

Internal export

+

get_metrics/0

+
+

get_metrics() -> any()

+
+ +

get_metrics/2

+
+

get_metrics(Host, Port) -> any()

+
+

handle_call/3

handle_call(Request, From, State) -> any()

@@ -168,35 +186,20 @@ send_req/4, send_req/5, send_req/6.

rescan_config/1

-

rescan_config(File) -> any()

+

rescan_config(Terms) -> any()

send_req/3

send_req(Url::string(), Headers::headerList(), Method::method()) -> response() -

+

This is the basic function to send a HTTP request. The Status return value indicates the HTTP status code returned by the webserver

send_req/4

send_req(Url, Headers, Method::method(), Body::body()) -> response() -

+

Same as send_req/3. If a list is specified for the body it has to be a flat list. The body can also be a fun/0 or a fun/1.
If fun/0, the connection handling process will repeatdely call the fun until it returns an error or eof.

Fun() = {ok, Data} | eof

@@ -205,106 +208,13 @@ send_req/4, send_req/5, send_req/6.

send_req/5

send_req(Url::string(), Headers::headerList(), Method::method(), Body::body(), Options::optionList()) -> response() -

-

Same as send_req/4. - For a description of SSL Options, look in the ssl manpage. If the - HTTP Version to use is not specified, the default is 1.1. -
-

-

+

+

Same as send_req/4.

send_req/6

send_req(Url, Headers::headerList(), Method::method(), Body::body(), Options::optionList(), Timeout) -> response() -

+

Same as send_req/5. All timeout values are in milliseconds.

@@ -338,14 +248,19 @@ data has been received on the link for a certain time interval.

Deprecated. Use set_max_sessions/3 and set_max_pipeline_size/3 for achieving the same effect.

+

set_max_attempts/3

+
+

set_max_attempts(Host::string(), Port::integer(), Max::integer()) -> ok

+

Set the maximum attempts for each connection to a specific Host:Port.

+

set_max_pipeline_size/3

-

set_max_pipeline_size(Host::string(), Port::integer(), Max::integer()) -> ok

+

set_max_pipeline_size(Host::string(), Port::integer(), Max::integer()) -> ok

Set the maximum pipeline size for each connection to a specific Host:Port.

set_max_sessions/3

-

set_max_sessions(Host::string(), Port::integer(), Max::integer()) -> ok

+

set_max_sessions(Host::string(), Port::integer(), Max::integer()) -> ok

Set the maximum number of connections allowed to a specific Host:Port.

show_dest_status/0

@@ -355,6 +270,11 @@ data has been received on the link for a certain time interval.

about workers spawned using spawn_worker_process/2 or spawn_link_worker_process/2 is not included.

+

show_dest_status/1

+
+

show_dest_status(Url) -> any()

+
+

show_dest_status/2

show_dest_status(Host, Port) -> any()

@@ -365,19 +285,18 @@ data has been received on the link for a certain time interval.

spawn_link_worker_process/1

-

spawn_link_worker_process(Url::string()) -> {ok, pid()}

+

spawn_link_worker_process(Url::string() | {Host::string(), Port::integer()}) -> {ok, pid()}

Same as spawn_worker_process/1 except the the calling process is linked to the worker process which is spawned.

spawn_link_worker_process/2

-

spawn_link_worker_process(Host::string(), Port::integer()) -> {ok, pid()}

-

Same as spawn_worker_process/2 except the the calling process - is linked to the worker process which is spawned.

+

spawn_link_worker_process(Host::string(), Port::integer()) -> {ok, pid()}

+

Same as spawn_link_worker_process/1 except with Erlang process options.

spawn_worker_process/1

-

spawn_worker_process(Url::string()) -> {ok, pid()}

+

spawn_worker_process(Url::string() | {Host::string(), Port::integer()}) -> {ok, pid()}

Creates a HTTP client process to the specified Host:Port which is not part of the load balancing pool. This is useful in cases where some requests to a webserver might take a long time whereas @@ -388,14 +307,12 @@ data has been received on the link for a certain time interval.

is setup. The connection attempt is made only when the first request is sent via any of the send_req_direct/4,5,6,7 functions.
Note: It is the responsibility of the calling process to control - pipeline size on such connections. -

+ pipeline size on such connections.

spawn_worker_process/2

-

spawn_worker_process(Host::string(), Port::integer()) -> {ok, pid()}

-

Same as spawn_worker_process/1 but takes as input a Host and Port - instead of a URL.

+

spawn_worker_process(Host::string(), Port::integer()) -> {ok, pid()}

+

Same as spawn_worker_process/1 except with Erlang process options.

start/0

@@ -404,7 +321,7 @@ data has been received on the link for a certain time interval.

start_link/0

-

start_link() -> {ok, pid()}

+

start_link() -> {ok, pid()}

Starts the ibrowse process linked to the calling process. Usually invoked by the supervisor ibrowse_sup

stop/0

@@ -414,14 +331,14 @@ data has been received on the link for a certain time interval.

stop_worker_process/1

-

stop_worker_process(Conn_pid::pid()) -> ok

+

stop_worker_process(Conn_pid::pid()) -> ok

Terminate a worker process spawned using spawn_worker_process/2 or spawn_link_worker_process/2. Requests in progress will get the error response

{error, closing_on_request}

stream_close/1

-

stream_close(Req_id::req_id()) -> ok | {error, unknown_req_id}

+

stream_close(Req_id::req_id()) -> ok | {error, unknown_req_id}

Tell ibrowse to close the connection associated with the specified stream. Should be used in conjunction with the stream_to option. Note that all requests in progress on @@ -430,7 +347,7 @@ data has been received on the link for a certain time interval.

stream_next/1

-

stream_next(Req_id::req_id()) -> ok | {error, unknown_req_id}

+

stream_next(Req_id::req_id()) -> ok | {error, unknown_req_id}

Tell ibrowse to stream the next chunk of data to the caller. Should be used in conjunction with the stream_to option

@@ -447,7 +364,7 @@ data has been received on the link for a certain time interval.

trace_off/2

-

trace_off(Host, Port) -> ok

+

trace_off(Host, Port) -> ok

Turn tracing OFF for all connections to the specified HTTP server.

@@ -459,14 +376,12 @@ data has been received on the link for a certain time interval.

trace_on/2

trace_on(Host, Port) -> ok -

+

Turn tracing on for all connections to the specified HTTP server. Host is whatever is specified as the domain name in the URL


add_config/1Add additional configuration elements at runtime.
all_trace_off/0Turn Off ALL tracing.
code_change/3
get_config_value/1Internal export.
get_config_value/2Internal export.
get_metrics/0
get_metrics/2
handle_call/3
handle_cast/2
handle_info/2
send_req_direct/7Same as send_req/6 except that the first argument is the PID returned by spawn_worker_process/2 or spawn_link_worker_process/2.
set_dest/3Deprecated.
set_max_attempts/3Set the maximum attempts for each connection to a specific Host:Port.
set_max_pipeline_size/3Set the maximum pipeline size for each connection to a specific Host:Port.
set_max_sessions/3Set the maximum number of connections allowed to a specific Host:Port.
show_dest_status/0Shows some internal information about load balancing.
show_dest_status/1
show_dest_status/2Shows some internal information about load balancing to a specified Host:Port.
spawn_link_worker_process/1Same as spawn_worker_process/1 except the the calling process is linked to the worker process which is spawned.
spawn_link_worker_process/2Same as spawn_worker_process/2 except the the calling process - is linked to the worker process which is spawned.
spawn_link_worker_process/2Same as spawn_link_worker_process/1 except with Erlang process options.
spawn_worker_process/1Creates a HTTP client process to the specified Host:Port which is not part of the load balancing pool.
spawn_worker_process/2Same as spawn_worker_process/1 but takes as input a Host and Port - instead of a URL.
spawn_worker_process/2Same as spawn_worker_process/1 except with Erlang process options.
start/0Starts the ibrowse process without linking.
start_link/0Starts the ibrowse process linked to the calling process.
stop/0Stop the ibrowse process.
Overviewerlang logo
-

Generated by EDoc, Nov 10 2010, 06:04:33.

+

Generated by EDoc, Nov 6 2015, 11:40:24.

diff --git a/doc/ibrowse_app.html b/doc/ibrowse_app.html new file mode 100644 index 0000000..368a4b3 --- /dev/null +++ b/doc/ibrowse_app.html @@ -0,0 +1,38 @@ + + + + +Module ibrowse_app + + + + +
+ +

Module ibrowse_app

+ + +

Behaviours: application.

+ +

Function Index

+ + +
start/2
stop/1
+ +

Function Details

+ +

start/2

+
+

start(Type, StartArgs) -> any()

+
+ +

stop/1

+
+

stop(State) -> any()

+
+
+ + +

Generated by EDoc, Nov 6 2015, 11:40:24.

+ + diff --git a/doc/ibrowse_http_client.html b/doc/ibrowse_http_client.html new file mode 100644 index 0000000..66f0f53 --- /dev/null +++ b/doc/ibrowse_http_client.html @@ -0,0 +1,98 @@ + + + + +Module ibrowse_http_client + + + + +
+ +

Module ibrowse_http_client

+ + +

Behaviours: gen_server.

+ +

Function Index

+ + + + + + + + + + + + +
code_change/3
handle_call/3
handle_cast/2
handle_info/2
init/1
send_req/7
start/1
start/2
start_link/1
start_link/2
stop/1
terminate/2
+ +

Function Details

+ +

code_change/3

+
+

code_change(OldVsn, State, Extra) -> any()

+
+ +

handle_call/3

+
+

handle_call(Request, From, State) -> any()

+
+ +

handle_cast/2

+
+

handle_cast(Msg, State) -> any()

+
+ +

handle_info/2

+
+

handle_info(Info, State) -> any()

+
+ +

init/1

+
+

init(Url) -> any()

+
+ +

send_req/7

+
+

send_req(Conn_Pid, Url, Headers, Method, Body, Options, Timeout) -> any()

+
+ +

start/1

+
+

start(Args) -> any()

+
+ +

start/2

+
+

start(Args, Options) -> any()

+
+ +

start_link/1

+
+

start_link(Args) -> any()

+
+ +

start_link/2

+
+

start_link(Args, Options) -> any()

+
+ +

stop/1

+
+

stop(Conn_pid) -> any()

+
+ +

terminate/2

+
+

terminate(Reason, State) -> any()

+
+
+ + +

Generated by EDoc, Nov 6 2015, 11:40:24.

+ + diff --git a/doc/ibrowse_lb.html b/doc/ibrowse_lb.html new file mode 100644 index 0000000..b115982 --- /dev/null +++ b/doc/ibrowse_lb.html @@ -0,0 +1,80 @@ + + + + +Module ibrowse_lb + + + + +
+ +

Module ibrowse_lb

+ + +

Behaviours: gen_server.

+ +

Function Index

+ + + + + + + + + +
code_change/3
handle_call/3
handle_cast/2
handle_info/2
init/1
spawn_connection/6
start_link/1
stop/1
terminate/2
+ +

Function Details

+ +

code_change/3

+
+

code_change(OldVsn, State, Extra) -> any()

+
+ +

handle_call/3

+
+

handle_call(Request, From, State) -> any()

+
+ +

handle_cast/2

+
+

handle_cast(Msg, State) -> any()

+
+ +

handle_info/2

+
+

handle_info(Info, State) -> any()

+
+ +

init/1

+
+

init(X1) -> any()

+
+ +

spawn_connection/6

+
+

spawn_connection(Lb_pid, Url, Max_sessions, Max_pipeline_size, SSL_options, Process_options) -> any()

+
+ +

start_link/1

+
+

start_link(Args) -> any()

+
+ +

stop/1

+
+

stop(Lb_pid) -> any()

+
+ +

terminate/2

+
+

terminate(Reason, State) -> any()

+
+
+ + +

Generated by EDoc, Nov 6 2015, 11:40:24.

+ + diff --git a/doc/ibrowse_lib.html b/doc/ibrowse_lib.html index 7a00d4f..4411692 100644 --- a/doc/ibrowse_lib.html +++ b/doc/ibrowse_lib.html @@ -1,67 +1,114 @@ + Module ibrowse_lib - + + +

Module ibrowse_lib

-Module with a few useful functions. - +Module with a few useful functions. +

Description

Module with a few useful functions

Function Index

- - - - - +
dec2hex/2dec2hex taken from gtk.erl in std dist - M = integer() -- number of hex digits required - N = integer() -- the number to represent as hex.
decode_base64/1Implements the base64 decoding algorithm.
decode_rfc822_date/1
drv_ue/1
drv_ue/2
+ + + + + + + + + +
decode_base64/1Implements the base64 decoding algorithm.
decode_rfc822_date/1
do_trace/2
do_trace/3
do_trace/3
encode_base64/1Implements the base64 encoding algorithm.
get_trace_status/2
get_value/2
get_value/3
parse_url/1
printable_date/0
printable_date/1
status_code/1Given a status code, returns an atom describing the status code.
url_encode/1URL-encodes a string based on RFC 1738.

Function Details

-

dec2hex/2

-

dec2hex(M::integer(), N::integer()) -> string()

-

dec2hex taken from gtk.erl in std dist - M = integer() -- number of hex digits required - N = integer() -- the number to represent as hex

+

decode_base64/1

+
+

decode_base64(List::In) -> Out | exit({error, invalid_input}) +

+

Implements the base64 decoding algorithm. The output data type matches in the input data type.

-

decode_base64/1

-

decode_base64(List::In) -> Out | exit({error, invalid_input}) -

-

Implements the base64 decoding algorithm. The output data type matches in the input data type.

+

decode_rfc822_date/1

+
+

decode_rfc822_date(String) -> any()

+
-

decode_rfc822_date/1

-decode_rfc822_date(String) -> term() - +

do_trace/2

+
+

do_trace(Fmt, Args) -> any()

+
-

drv_ue/1

-drv_ue(Str) -> term() - +

do_trace/3

+
+

do_trace(X1, Fmt, Args) -> any()

+
-

drv_ue/2

-drv_ue(Str, Port) -> term() - +

do_trace/3

+
+

do_trace(X1, Fmt, Args) -> any()

+
-

encode_base64/1

+

encode_base64/1

+

encode_base64(List::In) -> Out -

-

Implements the base64 encoding algorithm. The output data type matches in the input data type.

+

+

Implements the base64 encoding algorithm. The output data type matches in the input data type.

+ +

get_trace_status/2

+
+

get_trace_status(Host, Port) -> any()

+
+ +

get_value/2

+
+

get_value(Tag, TVL) -> any()

+
+ +

get_value/3

+
+

get_value(Tag, TVL, DefVal) -> any()

+
-

status_code/1

+

parse_url/1

+
+

parse_url(Url) -> any()

+
+ +

printable_date/0

+
+

printable_date() -> any()

+
+ +

printable_date/1

+
+

printable_date(Now) -> any()

+
+ +

status_code/1

+

status_code(StatusCode::status_code()) -> StatusDescription -

-

Given a status code, returns an atom describing the status code.

+

+

Given a status code, returns an atom describing the status code.

-

url_encode/1

+

url_encode/1

+

url_encode(Str) -> UrlEncodedStr -

-

URL-encodes a string based on RFC 1738. Returns a flat list.

+

+

URL-encodes a string based on RFC 1738. Returns a flat list.

+
+ + +

Generated by EDoc, Nov 6 2015, 11:40:24.

diff --git a/doc/ibrowse_socks5.html b/doc/ibrowse_socks5.html new file mode 100644 index 0000000..bddd420 --- /dev/null +++ b/doc/ibrowse_socks5.html @@ -0,0 +1,31 @@ + + + + +Module ibrowse_socks5 + + + + +
+ +

Module ibrowse_socks5

+ + + +

Function Index

+ +
connect/5
+ +

Function Details

+ +

connect/5

+
+

connect(Host, Port, Options, SockOptions, Timeout) -> any()

+
+
+ + +

Generated by EDoc, Nov 6 2015, 11:40:24.

+ + diff --git a/doc/ibrowse_sup.html b/doc/ibrowse_sup.html new file mode 100644 index 0000000..0e5226d --- /dev/null +++ b/doc/ibrowse_sup.html @@ -0,0 +1,38 @@ + + + + +Module ibrowse_sup + + + + +
+ +

Module ibrowse_sup

+ + +

Behaviours: supervisor.

+ +

Function Index

+ + +
init/1
start_link/0
+ +

Function Details

+ +

init/1

+
+

init(X1) -> any()

+
+ +

start_link/0

+
+

start_link() -> any()

+
+
+ + +

Generated by EDoc, Nov 6 2015, 11:40:24.

+ + diff --git a/doc/index.html b/doc/index.html new file mode 100644 index 0000000..657b98c --- /dev/null +++ b/doc/index.html @@ -0,0 +1,17 @@ + + + +The ibrowse application + + + + + + +<h2>This page uses frames</h2> +<p>Your browser does not accept frames. +<br>You should go to the <a href="overview-summary.html">non-frame version</a> instead. +</p> + + + \ No newline at end of file diff --git a/doc/modules-frame.html b/doc/modules-frame.html new file mode 100644 index 0000000..3d6f50c --- /dev/null +++ b/doc/modules-frame.html @@ -0,0 +1,18 @@ + + + +The ibrowse application + + + +

Modules

+ + + + + + + +
ibrowse
ibrowse_app
ibrowse_http_client
ibrowse_lb
ibrowse_lib
ibrowse_socks5
ibrowse_sup
+ + \ No newline at end of file diff --git a/doc/overview-summary.html b/doc/overview-summary.html new file mode 100644 index 0000000..b563096 --- /dev/null +++ b/doc/overview-summary.html @@ -0,0 +1,16 @@ + + + + +The ibrowse application + + + + +

The ibrowse application

+ +
+ +

Generated by EDoc, Nov 6 2015, 11:40:24.

+ + diff --git a/doc/stylesheet.css b/doc/stylesheet.css new file mode 100644 index 0000000..ab170c0 --- /dev/null +++ b/doc/stylesheet.css @@ -0,0 +1,55 @@ +/* standard EDoc style sheet */ +body { + font-family: Verdana, Arial, Helvetica, sans-serif; + margin-left: .25in; + margin-right: .2in; + margin-top: 0.2in; + margin-bottom: 0.2in; + color: #000000; + background-color: #ffffff; +} +h1,h2 { + margin-left: -0.2in; +} +div.navbar { + background-color: #add8e6; + padding: 0.2em; +} +h2.indextitle { + padding: 0.4em; + background-color: #add8e6; +} +h3.function,h3.typedecl { + background-color: #add8e6; + padding-left: 1em; +} +div.spec { + margin-left: 2em; + background-color: #eeeeee; +} +a.module { + text-decoration:none +} +a.module:hover { + background-color: #eeeeee; +} +ul.definitions { + list-style-type: none; +} +ul.index { + list-style-type: none; + background-color: #eeeeee; +} + +/* + * Minor style tweaks + */ +ul { + list-style-type: square; +} +table { + border-collapse: collapse; +} +td { + padding: 3 +} diff --git a/rebar b/rebar deleted file mode 100755 index 8e4deb6..0000000 Binary files a/rebar and /dev/null differ diff --git a/rebar.lock b/rebar.lock new file mode 100644 index 0000000..57afcca --- /dev/null +++ b/rebar.lock @@ -0,0 +1 @@ +[]. diff --git a/test/ibrowse_load_test.erl b/test/ibrowse_load_test.erl index 5ff308e..eef0aaf 100644 --- a/test/ibrowse_load_test.erl +++ b/test/ibrowse_load_test.erl @@ -36,11 +36,11 @@ start_1(Num_workers, Num_requests, Max_sess) -> {one_request_only, 0} ]), ibrowse:set_max_sessions("localhost", 8081, Max_sess), - Start_time = now(), + Start_time = os:timestamp(), Workers = spawn_workers(Num_workers, Num_requests), erlang:send_after(1000, self(), print_diagnostics), ok = wait_for_workers(Workers), - End_time = now(), + End_time = os:timestamp(), Time_in_secs = trunc(round(timer:now_diff(End_time, Start_time) / 1000000)), Req_count = Num_workers * Num_requests, [{_, Success_count}] = ets:lookup(?ibrowse_load_test_counters, success), @@ -95,7 +95,7 @@ spawn_workers(0, _Num_requests, _Parent, Acc) -> lists:reverse(Acc); spawn_workers(Num_workers, Num_requests, Parent, Acc) -> Pid_ref = spawn_monitor(fun() -> - random:seed(now()), + random:seed(os:timestamp()), case catch worker_loop(Parent, Num_requests) of {'EXIT', Rsn} -> io:format("Worker crashed with reason: ~p~n", [Rsn]); @@ -150,11 +150,11 @@ worker_loop(Parent, N) -> _ -> "http://localhost:8081/blah" end, - Start_time = now(), + Start_time = os:timestamp(), Res = ibrowse:send_req(Url, [], get), - End_time = now(), + End_time = os:timestamp(), Time_taken = trunc(round(timer:now_diff(End_time, Start_time) / 1000)), - ets:insert(ibrowse_load_timings, {now(), Time_taken}), + ets:insert(ibrowse_load_timings, {os:timestamp(), Time_taken}), case Res of {ok, "200", _, _} -> ets:update_counter(?ibrowse_load_test_counters, success, 1);