Author: fdmanana
Date: Wed Apr 13 08:52:30 2011
New Revision: 1091711
URL: http://svn.apache.org/viewvc?rev=1091711&view=rev
Log:
Add support for replication over IPv6 (part 2)
On redirect, enclose the IPv6 address between square brackets (RFC 2732).
Closes COUCHDB-665.
Modified:
couchdb/trunk/src/couchdb/couch_api_wrap_httpc.erl
Modified: couchdb/trunk/src/couchdb/couch_api_wrap_httpc.erl
URL:
http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_api_wrap_httpc.erl?rev=1091711&r1=1091710&r2=1091711&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_api_wrap_httpc.erl (original)
+++ couchdb/trunk/src/couchdb/couch_api_wrap_httpc.erl Wed Apr 13 08:52:30 2011
@@ -278,7 +278,8 @@ redirect_url(RespHeaders, OrigUrl) ->
MochiHeaders = mochiweb_headers:make(RespHeaders),
RedUrl = mochiweb_headers:get_value("Location", MochiHeaders),
#url{
- host = Base,
+ host = Host,
+ host_type = HostType,
port = Port,
path = Path, % includes query string
protocol = Proto
@@ -293,7 +294,13 @@ redirect_url(RespHeaders, OrigUrl) ->
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.
after_redirect(RedirectUrl, 303, HttpDb, Params) ->