[erlang-patches] tiny http-auth improvement for http-client

Igor Goryachev <>
Sun Mar 4 15:28:05 CET 2007


Hello everyone.

HTTP-client could not perform HTTP-Auth with weird user or password,
i.e. when password contains "/" symbol:

:~/http-client% erl
Erlang (BEAM) emulator version 5.5.3 [source] [async-threads:0] [kernel-poll:false]

Eshell V5.5.3  (abort with ^G)
1> http:request(get, {"http://igor:ac/dc@www.goryachev.org/photos/", []}, [], []).
{error,{malformed_url,"http://igor:ac/dc@www.goryachev.org/photos/"}}

I added an extra http option (#http_options{http_auth, % {User,
Password} = {string(), string()}}) which helps http-client to handle
arbitary user and password:

2> http:request(get, {"http://www.goryachev.org/photos/", []}, [{http_auth, {"igor", "ac/dc"}}], []).

=INFO REPORT==== 4-Mar-2007::17:07:56 ===
The inets application was not started. Has now been started as a
temporary application.
{ok,{{"HTTP/1.1",200,"OK"},
.....

With wrong password:

3> http:request(get, {"http://www.goryachev.org/photos/", []}, [{http_auth, {"igor", "ac\dc"}}], []).
{ok,{{"HTTP/1.1",401,"Unauthorized"},
.....

-------------- next part --------------
A non-text attachment was scrubbed...
Name: erlang_inets_http_auth_option.diff
Type: text/x-diff
Size: 2250 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-patches/attachments/20070304/81deca4b/attachment.bin>
-------------- next part --------------



-- 
    Igor Goryachev              E-Mail/Jabber: 


More information about the erlang-patches mailing list