Add strictly monotonic timestamp (#173)
diff --git a/src/ibrowse_http_client.erl b/src/ibrowse_http_client.erl
index 5443fe7..98a475f 100644
--- a/src/ibrowse_http_client.erl
+++ b/src/ibrowse_http_client.erl
@@ -484,6 +484,15 @@
State#state{reply_buffer = RepBuf_1}
end.
+generate_timestamp() ->
+ case catch erlang:unique_integer([positive]) of
+ {'EXIT', _} ->
+ erlang:apply(erlang, now, []);
+ Unique ->
+ {A,B,C} = os:timestamp(),
+ {A * 1000000 + B, C, Unique}
+ end.
+
make_tmp_filename(true) ->
DownloadDir = ibrowse:get_config_value(download_dir, filename:absname("./")),
{A,B,C} = os:timestamp(),
@@ -2050,12 +2059,7 @@
end.
make_req_id() ->
- case catch erlang:unique_integer() of
- {'EXIT', _} ->
- erlang:apply(erlang, now, []);
- V ->
- V
- end.
+ generate_timestamp().
to_lower(Str) when is_binary(Str) ->
to_lower(binary_to_list(Str));