From 1215e205668431d7a916c945285761280489e638 Mon Sep 17 00:00:00 2001 From: Filipe David Borba Manana Date: Wed, 13 Apr 2011 11:06:16 +0000 Subject: 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. git-svn-id: https://svn.apache.org/repos/asf/couchdb/branches/1.1.x@1091742 13f79535-47bb-0310-9956-ffa450edef68 --- src/couchdb/couch_rep_httpc.erl | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/couchdb/couch_rep_httpc.erl') diff --git a/src/couchdb/couch_rep_httpc.erl b/src/couchdb/couch_rep_httpc.erl index cfd815b4..bbe390a9 100644 --- a/src/couchdb/couch_rep_httpc.erl +++ b/src/couchdb/couch_rep_httpc.erl @@ -128,7 +128,7 @@ redirect_url(RespHeaders, OrigUrl) -> MochiHeaders = mochiweb_headers:make(RespHeaders), RedUrl = mochiweb_headers:get_value("Location", MochiHeaders), #url{ - host = Host, port = Port, + 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), @@ -138,7 +138,13 @@ redirect_url(RespHeaders, OrigUrl) -> false -> [] end, - atom_to_list(Proto) ++ "://" ++ Creds ++ Host ++ ":" ++ + 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) -> -- cgit v1.2.3