Author: fdmanana
Date: Wed Apr 13 11:21:28 2011
New Revision: 1091747
URL: http://svn.apache.org/viewvc?rev=1091747&view=rev
Log:
Backported revision 1091711 from trunk
Add support for replication over IPv6 (part 2)
On redirect, enclose the IPv6 address between square brackets (RFC 2732).
Closes COUCHDB-665.
Modified:
couchdb/branches/1.0.x/src/couchdb/couch_rep_httpc.erl
Modified: couchdb/branches/1.0.x/src/couchdb/couch_rep_httpc.erl
URL:
http://svn.apache.org/viewvc/couchdb/branches/1.0.x/src/couchdb/couch_rep_httpc.erl?rev=1091747&r1=1091746&r2=1091747&view=diff
==============================================================================
--- couchdb/branches/1.0.x/src/couchdb/couch_rep_httpc.erl (original)
+++ couchdb/branches/1.0.x/src/couchdb/couch_rep_httpc.erl Wed Apr 13 11:21:28
2011
@@ -123,15 +123,24 @@ config_http(Url) ->
redirect_url(RespHeaders, OrigUrl) ->
MochiHeaders = mochiweb_headers:make(RespHeaders),
RedUrl = mochiweb_headers:get_value("Location", MochiHeaders),
- {url, _, Base, Port, _, _, Path, Proto} = ibrowse_lib:parse_url(RedUrl),
- {url, _, _, _, User, Passwd, _, _} = ibrowse_lib:parse_url(OrigUrl),
+ #url{
+ host = Host, host_type = HostType, port = Port,
+ path = Path, protocol = Proto
+ } = ibrowse_lib:parse_url(RedUrl),
+ #url{username = User, password = Passwd} = ibrowse_lib:parse_url(OrigUrl),
Creds = case is_list(User) andalso is_list(Passwd) of
true ->
User ++ ":" ++ Passwd ++ "@";
false ->
[]
end,
- atom_to_list(Proto) ++ "://" ++ Creds ++ Base ++ ":" ++
+ HostPart = case HostType of
+ ipv6_address ->
+ "[" ++ Host ++ "]";
+ _ ->
+ Host
+ end,
+ atom_to_list(Proto) ++ "://" ++ Creds ++ HostPart ++ ":" ++
integer_to_list(Port) ++ Path.
full_url(#http_db{url=Url} = Req) when is_binary(Url) ->