Skip to content

Commit

Permalink
Merge pull request esl#47 from fogfish/master
Browse files Browse the repository at this point in the history
fix httpc timeout issue
  • Loading branch information
gleber committed Aug 27, 2013
2 parents 2996040 + 4aab149 commit 60108f1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion include/erlcloud_aws.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
ddb_retry=fun erlcloud_ddb_impl:retry/2::erlcloud_ddb_impl:retry_fun(),
access_key_id::string()|undefined|false,
secret_access_key::string()|undefined|false,
security_token=undefined::string()|undefined
security_token=undefined::string()|undefined,
timeout=10000::timeout()
}).
-type(aws_config() :: #aws_config{}).
7 changes: 5 additions & 2 deletions src/erlcloud_aws.erl
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,18 @@ aws_request2_no_update(Method, Protocol, Host, Port, Path, Params, #aws_config{}
_ -> URL = [UProtocol, Host, $:, port_to_str(Port), Path]
end,

%% Note: httpc MUST be used with {timeout, timeout()} option
%% Many timeout related failures is observed at prod env
%% when library is used in 24/7 manner
Response =
case Method of
get ->
Req = lists:flatten([URL, $?, Query]),
httpc:request(Req);
httpc:request(get, {Req, []}, [{timeout, Config#aws_config.timeout}], []);
_ ->
httpc:request(Method,
{lists:flatten(URL), [], "application/x-www-form-urlencoded; charset=utf-8",
list_to_binary(Query)}, [], [])
list_to_binary(Query)}, [{timeout, Config#aws_config.timeout}], [])
end,

http_body(Response).
Expand Down

0 comments on commit 60108f1

Please sign in to comment.