Forum Discussion

skbartl_85400's avatar
skbartl_85400
Icon for Nimbostratus rankNimbostratus
Mar 26, 2008

Determine URI after setting with HTTP::uri

I have an iRule that uses HTTP::uri to rewrite part of the original URI. For debugging purposes, I would like to write out the value of the new URI to the log. Below is the basic gist of my iRule:

 

 

------------------------------------------

 

log local.0 "URI before: [HTTP::uri]"

 

HTTP::uri $new_uri

 

log local.0 "URI after: [HTTP::uri]"

 

------------------------------------------

 

 

The log entries for before and after both have the original URI, not the new URI. Is there any way to get the value of the new URI after changing it with HTTP::uri (in the context of HTTP_REQUEST)? I did find a workaround with the following code, but I was hoping to find a more elegant solution.

 

 

------------------------------------------

 

when HTTP_REQUEST_SEND {

 

clientside { log local0. "New URI: [HTTP::uri]" }

 

}

 

------------------------------------------

 

 

Any ideas?

 

 

Thanks!

 

 

Steve

3 Replies

  • Try this

    
    log local0. "URI before: [HTTP::uri]"
    set new_uri "[HTTP::uri]\blah\blah"
    log local0. "URI after: $new_uri"

    /cb

  • That doesn't seem to assign anything to the variable. It looks like when HTTP::uri is used in the context of setting the uri (vs. reading it), the return value is not the new URI, but rather the status of the assignment.
  • The value for HTTP::uri and most other HTTP:: commands is cached in the same event and priority. So even if you modify the URI with HTTP::uri, logging the value of HTTP::uri will still return the original value. As cmbhatt pointed out, you can save the new value to a variable and then log it. Or to double check the change, you can add a log statement in HTTP_REQUEST priority 501. This should be removed once you're done testing as it adds unnecessary load.

     

     

    Aaron