[erlang-questions] Re : http client bug in inets when following relative redirects
Elias Torres
elias@REDACTED
Tue Feb 10 02:47:48 CET 2009
Ingela,
Thanks for looking into this. I wanted to give you something better
than just 'this code smells' so I did a first pass of implementing
urlsplit, urlunsplit, urljoin a la 'python' based on RFC 3986.
In case you don't get the attached code, I've uploaded to pastebin.
http://pastebin.com/m139cf371
I would appreciate anybody taking a look at the code and giving me
feedback, I'm sure things could be done better. If ibrowse/mochiweb
folks are interested in the function, please feel free to take it as
well.
-Elias
On Mon, Feb 9, 2009 at 4:43 AM, Ingela Anderton Andin
<ingela@REDACTED> wrote:
> Hi!
>
>> [eliast@REDACTED] /usr/local/lib/erlang/lib/inets-5.0.12/src $ erl -s inets
>
>> Eshell V5.6.5 (abort with ^G)
>> 1> http:request(get, {"http://mohegansun.com/",[]}, [{autoredirect,
>> true},{relaxed, true}],[]).
>> error,{badarg,[{erlang,'++',[80,"//gateway/index.html"]},
> {httpc_response,fix_relative_uri,2},
> {httpc_response,redirect,2},
> {httpc_handler,handle_response,1},
> {gen_server,handle_msg,5},
> {proc_lib,init_p_do_apply,3}]}}
>
>> In httpc_response.erl:fix_relative_uri/2 I found the following:
>
>> fix_relative_uri(Request, RedirUrl) ->
>> {Server, Port} = Request#request.address,
>> Path = Request#request.path,
>> atom_to_list(Request#request.scheme) ++ "://" ++ Server ++ ":" ++ Port
>> ++ Path ++ RedirUrl.
>
>> It's choking when concatenating Port which is an integer. For now I
>> have wrapped Port with an integer_to_list call, but this function
>> really smells bad. For example, it grabs the original path and simply
>> concatenates it with the redirect path. In this case "/" +
>> "/gateway/index.html" == "//gateway/index.html" but what if the
>>original path was /old_working_link"?
>
> Thank you for pointing this out, we will look into the issue.
>
>> Thanks for you attention to the matter. If there's an official place
>> to submit this bug please let me know.
>
> erlang-bugs<AT>erlang.org Change <AT> to @
>
> You can subscrie to it here:
> http://www.erlang.org/faq.html
>
> Ingela Erlang/OTP - Ericsson
>
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: http_uri_elias.erl
Type: application/octet-stream
Size: 10079 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20090209/eb886915/attachment.obj>
More information about the erlang-questions
mailing list