Skip to content

lhttpc crashing too easily? #47

@robertoaloi

Description

@robertoaloi

[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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions