Skip to content

Commit

Permalink
Fix some issues related with comments in PR 15.
Browse files Browse the repository at this point in the history
  • Loading branch information
lastres committed Jan 14, 2013
1 parent 0a2a640 commit 2143caf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 28 deletions.
16 changes: 8 additions & 8 deletions src/lhttpc.erl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
delete_pool/1]).
-export([
send_body_part/2,
send_body_part/3,
send_body_part/3,
send_trailers/2,
send_trailers/3
]).
Expand Down Expand Up @@ -98,7 +98,7 @@ start() ->
stop() ->
application:stop(lhttpc).

%% @spec (Name) -> {ok, Pid} | {error, Reason}
%% @spec (Name) -> {ok, Pid} | {error, Reason}
%% Name = atom()
%% Pid = pid()
%% Reason = term()
Expand Down Expand Up @@ -135,8 +135,8 @@ add_pool(Name, ConnTimeout, PoolSize) ->
{pool_size, PoolSize}]]},
permanent, 10000, worker, [lhttpc_manager]},
case supervisor:start_child(lhttpc_sup, ChildSpec) of
{error, {already_started, Pid}} ->
{ok, Pid};
{error, {already_started, _Pid}} ->
{error, already_exists};
{error, Error} ->
{error, Error};
{ok, Pid} ->
Expand Down Expand Up @@ -248,7 +248,7 @@ request(URL, Method, Hdrs, Body, Timeout) ->
%% request(Host, Port, Path, Ssl, Method, Hdrs, Body, Timeout, Options).
%% </pre>
%%
%% `URL' is expected to be a valid URL:
%% `URL' is expected to be a valid URL:
%% `scheme://host[:port][/path]'.
%% @end
%% @see request/9
Expand Down Expand Up @@ -344,7 +344,7 @@ request(URL, Method, Hdrs, Body, Timeout, Options) ->
%% choose to give up earlier than the connect timeout, in which case the
%% client will also give up. The default value is infinity, which means that
%% it will either give up when the TCP stack gives up, or when the overall
%% request timeout is reached.
%% request timeout is reached.
%%
%% `{connect_options, Options}' specifies options to pass to the socket at
%% connect time. This makes it possible to specify both SSL options and
Expand Down Expand Up @@ -464,9 +464,9 @@ send_body_part({Pid, Window}, IoList) ->
%% milliseconds. If there is no acknowledgement received during that time the
%% the request is cancelled and `{error, timeout}' is returned.
%%
%% As long as the window size is larger than 0 the function will return
%% As long as the window size is larger than 0 the function will return
%% immediately after sending the body part to the request handling process.
%%
%%
%% The `BodyPart' `http_eob' signals an end of the entity body, the request
%% is considered sent and the response will be read from the socket. If
%% there is no response within `Timeout' milliseconds, the request is
Expand Down
26 changes: 6 additions & 20 deletions src/lhttpc_client.erl
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ ensure_call(Pool, SocketRequest, Options) ->
%% Opening a new HTTP/1.1 connection
undefined
catch
exit:{noproc, {gen_server, call, [Pool, S, T]}} ->
exit:{noproc, Reason} ->
case proplists:get_value(pool_ensure, Options, false) of
true ->
{ok, DefaultTimeout} = application:get_env(
Expand All @@ -200,20 +200,12 @@ ensure_call(Pool, SocketRequest, Options) ->
ensure_call(Pool, SocketRequest, Options);
_ ->
%% Failed to create pool, exit as expected
exit({error, {noproc, {gen_server,
call,
[Pool, S, T]}}})
exit({noproc, Reason})
end;
false ->
%% No dynamic pool creation, exit as expected
exit({error, {noproc, {gen_server,
call,
[Pool, S, T]}}})
end;
exit:M ->
exit(M);
error:M ->
error(M)
exit({noproc, Reason})
end
end.

send_request(#client_state{attempts = 0}) ->
Expand Down Expand Up @@ -248,14 +240,8 @@ send_request(#client_state{socket = undefined} = State) ->
exit:{{{badmatch, {error, {asn1, _}}}, _}, _} ->
throw(ssl_decode_error);
Type:Error ->
case Type of
exit ->
Stack = erlang:get_stacktrace(),
error_logger:error_msg("Unexpected Exit: ~p ~p", [Error, Stack]),
erlang:error(Error, Stack);
Type ->
erlang:Type(Error, erlang:get_stacktrace())
end
error_logger:error_msg("Socket connection error: ~p ~p, ~p",
[Type, Error, erlang:get_stacktrace()])
end;
send_request(#client_state{proxy = #lhttpc_url{}, proxy_setup = false} = State) ->
#lhttpc_url{
Expand Down

0 comments on commit 2143caf

Please sign in to comment.