Passa al contenuto principale

5. Risoluzione dei riferimenti (Reference Resolution)

Questa sezione descrive l'algoritmo per risolvere i riferimenti URI in forma assoluta.

5.1. Stabilire un URI di base (Establishing a Base URI)​

La risoluzione dei riferimenti relativi richiede un URI di base. L'URI di base può essere stabilito attraverso vari metodi.

5.1.1. URI di base incorporato nel contenuto (Base URI Embedded in Content)​

Meccanismi come il tag <base> HTML possono specificare l'URI di base all'interno del contenuto.

5.1.2. URI di base dall'entità incapsulante (Base URI from the Encapsulating Entity)​

Un'entità incapsulante (come un messaggio MIME) può definire l'URI di base.

5.1.3. URI di base dall'URI di recupero (Base URI from the Retrieval URI)​

Se nessun altro URI di base è disponibile, utilizzare l'URI da cui è stato recuperato il documento.

5.1.4. URI di base predefinito (Default Base URI)​

Le applicazioni possono definire un URI di base predefinito.

5.2. Risoluzione relativa (Relative Resolution)​

Pseudocodice per l'algoritmo di risoluzione dei riferimenti relativi:

if R.scheme is defined then
T.scheme = R.scheme
T.authority = R.authority
T.path = remove_dot_segments(R.path)
T.query = R.query
else
if R.authority is defined then
T.authority = R.authority
T.path = remove_dot_segments(R.path)
T.query = R.query
else
if R.path is empty then
T.path = Base.path
if R.query is defined then
T.query = R.query
else
T.query = Base.query
else
if R.path starts-with "/" then
T.path = remove_dot_segments(R.path)
else
T.path = merge(Base, R.path)
T.path = remove_dot_segments(T.path)
T.query = R.query
T.authority = Base.authority
T.scheme = Base.scheme
T.fragment = R.fragment

5.3. Ricomposizione dei componenti (Component Recomposition)​

Ricombinare i componenti risolti in una stringa URI.

5.4. Esempi di risoluzione dei riferimenti (Reference Resolution Examples)​

URI di base: http://a/b/c/d;p?q

Riferimento relativoRisultato risolto
ghttp://a/b/c/g
./ghttp://a/b/c/g
g/http://a/b/c/g/
/ghttp://a/g
//ghttp://g
?yhttp://a/b/c/d;p?y
g?yhttp://a/b/c/g?y
#shttp://a/b/c/d;p?q#s
../ghttp://a/b/g
../../ghttp://a/g

Capitolo successivo: 6. Normalizzazione e confronto (Normalization and Comparison) - Tecniche di normalizzazione URI