Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lhttpc crashing too easily? #47

Open
robertoaloi opened this issue May 17, 2014 · 0 comments
Open

lhttpc crashing too easily? #47

robertoaloi opened this issue May 17, 2014 · 0 comments

Comments

@robertoaloi
Copy link
Contributor

[Pasted from an email I got from a lhttpc user]

For certain bad input lhttpc will crash with an exception rather than returning {error, Reason} with sensible reason.

While the input might be invalid, I still think it would be nice if it was handled internally i lhttpc, especially since badarg is a pretty vague error. All of these invalid inputs are handled gracefully by httpc on the other hand.

Some examples that I have encountered:

Non ascii characters:

% Latin-1 "å"

lhttpc:request("http://www.dammsugarpåsar.nu", get, [], 1000).
** exception exit: badarg

% Ascii bell

lhttpc:request("http://www." ++ [7] ++ ".com", get, [], 1000).
** exception exit: badarg

% Bigger than byte()

lhttpc:request("http://www." ++ [256] ++ ".com", get, [], 1000).
** exception exit: badarg

% Nothing after "http://"

lhttpc:request("http://", get, [], 1000).
** exception exit: badarg

% Emptry string

lhttpc:request("", get, [], 1000).
** exception error: no function clause matching
lhttpc_lib:split_scheme([]) (src/lhttpc_lib.erl, line 109)
in function lhttpc_lib:parse_url/1 (src/lhttpc_lib.erl, line 104)
in call from lhttpc:request/6 (src/lhttpc.erl, line 177)

% Omit "http://"

lhttpc:request("www.google.com", get, [], 1000).
** exception error: no function clause matching
lhttpc_lib:split_scheme("www.google.com") (src/lhttpc_lib.erl, line 109)
in function lhttpc_lib:parse_url/1 (src/lhttpc_lib.erl, line 104)
in call from lhttpc:request/6 (src/lhttpc.erl, line 177)

% Non-existing domain name

lhttpc:request("http://www.thisurldoesntexist.com", get, [], 1000).
** exception exit: {nxdomain,
[{lhttpc_client,send_request,1,
[{file,"src/lhttpc_client.erl"},{line,175}]},
{lhttpc_client,execute,9,
[{file,"src/lhttpc_client.erl"},{line,132}]},
{lhttpc_client,request,9,
[{file,"src/lhttpc_client.erl"},{line,79}]}]}
in function lhttpc:request/9 (src/lhttpc.erl, line 323)

g-andrade pushed a commit to g-andrade/lhttpc that referenced this issue Nov 26, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant