Non è possibile modificare qualsiasi parte dell'autorità (vale a dire la host: port parte) negli URL relativi. Vedere l'algoritmo descritto in section 5.2.2 di RFC 3986 per vedere come vengono interpretati gli URL relativi. È importante notare che l'autorità viene semplicemente copiata dall'URL di base o dall'URL che viene risolto e la struttura dell'autorità non viene mai interpretata. Ciò implica che non è possibile modificare nessuna delle sue parti, inclusa la parte della porta.
Ecco l'algoritmo in pseudo-codice copiato dal RFC:
-- The URI reference is parsed into the five URI components
--
(R.scheme, R.authority, R.path, R.query, R.fragment) = parse(R);
-- A non-strict parser may ignore a scheme in the reference
-- if it is identical to the base URI's scheme.
--
if ((not strict) and (R.scheme == Base.scheme)) then
undefine(R.scheme);
endif;
if defined(R.scheme) then
T.scheme = R.scheme;
T.authority = R.authority;
T.path = remove_dot_segments(R.path);
T.query = R.query;
else
if defined(R.authority) then
T.authority = R.authority;
T.path = remove_dot_segments(R.path);
T.query = R.query;
else
if (R.path == "") then
T.path = Base.path;
if defined(R.query) then
T.query = R.query;
else
T.query = Base.query;
endif;
else
if (R.path starts-with "/") then
T.path = remove_dot_segments(R.path);
else
T.path = merge(Base.path, R.path);
T.path = remove_dot_segments(T.path);
endif;
T.query = R.query;
endif;
T.authority = Base.authority;
endif;
T.scheme = Base.scheme;
endif;
T.fragment = R.fragment;
fonte
2011-11-29 21:00:26
Non credo che si può. La porta fa effettivamente parte del nome di dominio in questo contesto. Specificando il nome del dominio senza la porta (non usando un collegamento relativo) si fornisce fondamentalmente un dominio _differente_. –
Vedi anche http://stackoverflow.com/q/6016120/60075 –