Forum Discussion

Abdessamad_851's avatar
Abdessamad_851
Icon for Nimbostratus rankNimbostratus
Apr 24, 2018

URI rewrite in HTTP_REQUEST_DATA

Dear,

 

I just noticed a weird behavior I wanted to check here if anyone saw it before or know the reasons behind.

 

if we use HTTP::uri to change the uri of a POST request in HTTP_REQUEST_DATA event, the F5 will send a 302 redirect with the new uri instead of simply continue processing the request with the new uri.

 

Basically the code would look like this:

 

when HTTP_REQUEST {
    set uri [HTTP::uri]
    if { ($uri starts_with "/uri/to/change") and ([HTTP::method] eq "POST")}{
        HTTP::collect [HTTP::header content-length]

    }
}
when HTTP_REQUEST_DATA {
     Parse the collected payload
    set payload [HTTP::payload]
    if {[URI::query "?$payload" param1] ne ""} {
            HTTP::uri "/new/uri"
        HTTP::release
        return
    }
}

Thanks.

 

  • Hi,

    Maybe you can provide a 307 redirect to the user forcing him to POST again to the right URL :

    when HTTP_REQUEST_DATA {
         Parse the collected payload
        set payload [HTTP::payload]
        if {[URI::query "?$payload" param1] ne ""} {
            HTTP::respond 307 noserver Location "/new/uri"
        }
    }
    

    Regards

    Yann