[erlang-patches] Proposed patch to httpc_response.erl (R13A)

mtalyans mtalyans@REDACTED
Wed Apr 8 18:11:09 CEST 2009


Hi,

I am new to Erlang, so please bear with me:

Fix_relative_uri function was giving me errors, because Port variable is not
a list, but an integer, and ++ operator bombed.

Proposed patch (tested on several web pages with relative URI on the
Location response, found working fine):

mtalyans@REDACTED$ diff -Naur httpc_response.erl.orig httpc_response.erl
--- httpc_response.erl.orig    2009-04-08 09:02:44.000000000 -0700
+++ httpc_response.erl    2009-04-08 09:03:12.000000000 -0700
@@ -364,13 +364,18 @@
         end
     end.
 
+list_port(Port) when is_list(Port) ->
+    Port;
+list_port(Port) when is_integer(Port) ->
+    integer_to_list(Port).
+
 %%% Guessing that we received a relative URI, fix it to become an
absoluteURI
 fix_relative_uri(Request, RedirUrl) ->
     {Server, Port} = Request#request.address,
     Path = Request#request.path,
-    atom_to_list(Request#request.scheme) ++ "://" ++ Server ++ ":" ++ Port
-    ++ Path ++ RedirUrl.
-    
+    atom_to_list(Request#request.scheme) ++ "://" ++ Server ++ ":" ++
list_port(Port)
+        ++ Path ++ RedirUrl.
+
 error(#request{id = Id}, Reason) ->
     {Id, {error, Reason}}.

Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-patches/attachments/20090408/9609607a/attachment.htm>


More information about the erlang-patches mailing list