Technical Forum
Ask questions. Discover Answers.
Showing results for 
Search instead for 
Did you mean: 
Custom Alert Banner

HTTP::uri returns full URL

I have had reason to log HTTP::uri while troubleshooting an error on a new Virtual Server. When I log HTTP::uri I see the full URL including protocol, for example,



I was anticipating only seeing






Can anybody explain what is happening here? This goes against everything I thought I understood about HTTP::uri.







Hi Fergu,



An HTTP request can contain an absolute URI per RFC2616:



5.1.2 Request-URI




The Request-URI is a Uniform Resource Identifier (section 3.2) and


identifies the resource upon which to apply the request.



Request-URI = "*" | absoluteURI | abs_path | authority



The four options for Request-URI are dependent on the nature of the


request. The asterisk "*" means that the request does not apply to a


particular resource, but to the server itself, and is only allowed


when the method used does not necessarily apply to a resource. One


example would be






The absoluteURI form is REQUIRED when the request is being made to a


proxy. The proxy is requested to forward the request or service it


from a valid cache, and return the response. Note that the proxy MAY


forward the request on to another proxy or directly to the server


specified by the absoluteURI. In order to avoid request loops, a


proxy MUST be able to recognize all of its server names, including


any aliases, local variations, and the numeric IP address. An example


Request-Line would be:






To allow for transition to absoluteURIs in all requests in future


versions of HTTP, all HTTP/1.1 servers MUST accept the absoluteURI


form in requests, even though HTTP/1.1 clients will only generate


them in requests to proxies.




You can detect a relative URI by checking if HTTP::uri or HTTP::path start with "/". If not, it should be an absolute URI. You can use the URI:: commands to parse an absolute URI into the protocol, host and relative URI/path:





Hey Hoolio,


Firstly, can I just say that my friend LyonsG and I are continually impresses by your seemingly endless knowledge and your everpresence on DevCentral - do you ever sleep?;-P Thanks for taking the time to help 😉



Secondly your excerpt from the RFC answers my question. This latest project I'm working on is to load balance some proxy servers! So the quote...




The absoluteURI form is REQUIRED when the request is being made to a proxy.

nails it;-D



I have been writing iRules for a fair while (admittedly never in relation to proxy servers) but I have not come across this absoloute format when using HTTP::uri.



I think the Wiki page for HTTP::uri could really do with being updated to include a reference to the quote from your previous reply or the full RFC.



At the moment the Wiki page suggests the HTTP::uri will return something beginning with / i.e. something relative. If you read closely the Wiki page does says 'typically' but I only spotted this in hindsight and I imagine others have missed it too.



What do you think?





There's an RFE for this, BZ222409. You could open a case with F5 Support and ask them to attach it to the RFE.

For now, you can add logic to your iRule to handle relative and absolute URIs:


 Check for an absolute URI
if {not ([HTTP::uri] starts_with "/")}{

if {[scan $abs_uri {%[^/]//%[^/]%s} proto host uri] == 3}{

 Log the URI to a local URI
log local0. "\$proto: $proto, \$host: $host, \$uri: $uri"


Historic F5 Account
That RFE is for changing HTTP::path, not HTTP::uri. You could open up a new RFE for adding a new command to get only the relative part of the URI, and I would encourage you to do so.