Forum Discussion
Pedro_Madeira_7
Sep 10, 2008Nimbostratus
Based on sample codes I found in dev central I was able to glue some code together to try and read the http 303 response.
I need your help to confirm me if this iRule has the correct syntax and if it will work. This afternoon I'm thinking on going to the end customer facilities and try this code.
The iRule I wanna test is:
when HTTP_RESPONSE {
if { [HTTP::is_redirect] }{
if { [findstr [HTTP::uri]] contains "85.88.135.19"} {
pool link_colt
} elseif { [findstr [HTTP::uri]] contains "213.58.138.182"} {
pool link_oni
}
}
The objective is to read the Location string supplied with the HTTP 303 sent from youtube.com.
Let me remind you the http 303 response sent.
HTTP/1.x 303 See Other
Date: Fri, 05 Sep 2008 14:17:52 GMT
Server: Apache
Expires: Tue, 27 Apr 1971 19:44:06 EST
Cache-Control: no-cache
Location: http://v1.cache.googlevideo.com/get_video?video_id=gnZft1YTcA0&origin=ash-v190.ash.youtube.com&signature=CC4D530B3C7758DC76526042C6AD7D8B54352A4C.5629ADFF90E52BCA9E002A8583ACA62C466BCB8C&ip=85.88.135.195&ipbits=8&expire=1220645872&key=yt1&sver=2Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Proxy-Connection: Keep-Alive
Connection: Keep-Alive
So basically if you look at the Location header field you will see that within that string it's mentioned the public IP with which the client leaves out to the internet.
One of the doubts I have regarding the iRule I built is that I think I'm lacking a code line to make the user leave through the same link when he follows the HTTP 303 indication.
Because the user first makes a request to youtube.com, then he gets the HTTP 303 and then he visits a different domain where google's video caching servers are located. In the iRule I built I think I'm lacking a way to follow the entire session, and when the user gets the http 303, his next request should go through one of either ISPs based on the string found when I read the Location field from the 303 response.