Forum Discussion

Chris_Phillips's avatar
Chris_Phillips
Icon for Nimbostratus rankNimbostratus
Nov 22, 2006

HTTPtoHTTPSredirect example not working

Hi,

 

 

a fair few threads with titles like this, but don't seem to be asking my question here...

 

 

i'm trying to use that example code:

 

 

when HTTP_REQUEST {
  HTTP::redirect https://[getfield [HTTP::host] ":" 1][HTTP::uri]
}

 

but it doesn't even make sense to me reading it. using an example of "http://example.com/index.php" the consitutent parts are:

 

 

1) HTTP::host = example.com

 

2) [getfield [HTTP::host] ":" 1] = example.com

 

3) HTTP::uri = http://example.com/index.php

 

 

so the HTTP::redirect line ends up looking like "https://example.comhttp://example.com/index.php" which is clearly not useful! presumably HTTP::uri is only meant to read "/index.php" ? That's certainly not what my copy of IE6 is saying...

 

No.     Time        Source                Destination           Protocol Info                                                        
     85 1.506783    10.224.21.17          10.224.0.11           HTTP     GET http://cms.national.ncrs.nhs.uk/testurl.php HTTP/1.0 
Frame 85 (482 bytes on wire, 482 bytes captured)
Ethernet II, Src: DellPcba_d0:b7:2c (00:0d:56:d0:b7:2c), Dst: All-HSRP-routers_01 (00:00:0c:07:ac:01)
Internet Protocol, Src: 10.224.21.17 (10.224.21.17), Dst: 10.224.0.11 (10.224.0.11)
Transmission Control Protocol, Src Port: 3617 (3617), Dst Port: 8080 (8080), Seq: 0, Ack: 0, Len: 428
Hypertext Transfer Protocol
    GET http://cms.national.ncrs.nhs.uk/testurl.php HTTP/1.0\r\n
        Request Method: GET
        Request URI: http://cms.national.ncrs.nhs.uk/testurl.php
        Request Version: HTTP/1.0
    Accept: image/gif, image/x-xbitmap, image/jpeg, [etc...]\r\n
    Accept-Language: en-gb\r\n
    User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)\r\n
    Host: cms.national.ncrs.nhs.uk\r\n
    Proxy-Connection: Keep-Alive\r\n
    \r\n

5 Replies

  • That is IE's interpretation of what a URI is. There is a difference between a URI and and URL. I'm not going to get this started into a heated debate here but our interpretation of the breakdown of a URL is the following:

     

     

    protocol://[HTTP::host][HTTP::uri][HTTP::query]

     

     

    (I can't remember if the HTTP::query contains the question mark or not, I'll have to check that one out.

     

     

    So for

     

     

    http://www.foo.com/somepath/somefile.ext?foo=bar

     

     

    HTTP::host - www.foo.bar

     

    HTTP::uri - /somepath/somefile.ext

     

    HTTP::query - foo=bar (maybe with the beginning question mark).

     

     

    Hope this clears things up.

     

     

    -Joe
  • Joe,

     

     

    i'm clear on what is *meant* to happen, but that's not what *is* happening. With logging on my iRule i can see that i really do get sent to "https://example.comhttp://example.com/index.php" using IE, curl, Firefox etc...
  • I forgot to note:

     

     

    These examples are very dependent on the URI not containing double forward slashes (//). It all goes to pieces if the URI isn't absolute and the relative URI has //.

     

     

    [Edit...]

     

     

    Though, I guess you could build in logic to look for // only before the first /. That should cover all cases of absolute and relative URIs, except a relative URI that starts with a double forward slash (like //path/to/index.html). If you really wanted to cover all the bases, you could treat any URI that starts with // as a relative URI.

     

     

    Aaron
  • Thanks for that Aaron, I take this means that i'm right in seeing this confusion... from my perspective this seems like a very significant issue to not already be well known here. it's celar there are many potentially valid forms of data, and i'd have thought that in line with the previosuly clear and simple structure joe provided, there should already be some sort of mechanism with iRules code to be able to pull these url components out regardless of the original data format.
  • I can appreciate that. This is only my reading of the RFC's. I'm not in development so I can't speak to whether/why it's not known/handled well, but I would suggest you contact support to document it in a case and get an official response. That's the best channel for getting changes made to the product.

     

     

    Thanks,

     

    Aaron