Forum Discussion

bdo_isd_28658's avatar
bdo_isd_28658
Icon for Nimbostratus rankNimbostratus
Feb 20, 2007

iRule for replacing string in HTTP POST

I am having trouble even getting started on this iRule and would love some help.

 

 

We have an application (TAM) that is sending an incorrect HTTP POST to a back end application (APEX). We need to add an additional parameter to the HTTP POST.

 

 

My HTTP Header that needs changing is currently:

 

POST /pls/htmldb/wwv_flow.accept HTTP/1.1

 

Host: oratst1:7777

 

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1

 

Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5

 

Accept-Language: en-gb,en;q=0.5

 

Accept-Encoding: gzip,deflate

 

Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7

 

Keep-Alive: 300

 

Proxy-Connection: keep-alive

 

Referer: http://oratst1:7777/pls/htmldb/f?p=105

 

Cookie: ORACLE_PLATFORM_REMEMBER_UN=ADMIN:AMS_TST

 

Content-Type: application/x-www-form-urlencoded

 

Content-Length: 210

 

p_flow_id=105&p_flow_step_id=101&p_instance=9615267773042070588&p_page_submission_id=96363&p_request=LOGIN&p_t01=username&p_arg_names=1035622032913287&p_t02=password&p_md5_checksum=

 

 

I need the last line of the header above to actually read:

 

p_flow_id=105&p_flow_step_id=101&p_instance=9615267773042070588&p_page_submission_id=96363&p_request=LOGIN&p_arg_names=1035510424913285&p_t01=bdoadmin&p_arg_names=1035622032913287&p_t02=standard&p_md5_checksum=

 

 

The addition of "&p_arg_names=1035510424913285" is the change.

 

 

Could anyone suggest a starting point? What event to use for this?

 

 

Thank you & Kind Regards

 

Kate (kate.spath@bdo.co.uk)

6 Replies

  •  

    Are there any restrictions for replacing the header portion of the POST.

     

     

    My code seems to blank it out altogether.

     

     

    if { $method equals "POST"} {

     

     

    log local0. "----------------------------"

     

    set method [HTTP::method]

     

    log local0. "method = $method"

     

    log local0. [HTTP::header POST]

     

    set newpost [concat $path$basename HTTP/1.1]

     

    log local0. "newpost = $newpost"

     

    HTTP::header replace "POST" $newpost

     

    log local0. "POST + [HTTP::header POST]"

     

    log local0. "----------------------------"

     

    }

     

     

    Which generates:

     

     

    Feb 20 18:43:39 tmm tmm[12387]: Rule IAJB : ----------------------------

     

    Feb 20 18:43:39 tmm tmm[12387]: Rule IAJB : method = POST

     

    Feb 20 18:43:39 tmm tmm[12387]: Rule IAJB : //stgws04.nyenet.state.ny.us/siteminderagent/dmsforms/doLogin.fcc HTTP/1.0

     

    Feb 20 18:43:39 tmm tmm[12387]: Rule IAJB : newpost = /siteminderagent/dmsforms/doLogin.fcc HTTP/1.1

     

    Feb 20 18:43:39 tmm tmm[12387]: Rule IAJB : POST +

     

    Feb 20 18:43:39 tmm tmm[12387]: Rule IAJB : ----------------------------

     

     

    Cole

     

  • Using the original poster's request example with a request line of "POST /pls/htmldb/wwv_flow.accept HTTP/1.1", the request method is POST, which you can get/set using [HTTP::method]. The URI (in f5's terminology) is /pls/htmldb/www_flow.accept, which you can get/set using [HTTP::uri]. The version is 1.1, which you can get/set using [HTTP::version].

     

     

    I didn't expect the HTTP::header command to actually work against the request line. It looks like TMM might be seeing "POST http://..." and parsing it as a header by grabbing everything up to the ":". That's just a guess though, seeing as the value of that header is "//stgws04.nyenet.state.ny.us/siteminderagent/dmsforms/doLogin.fcc HTTP/1.0"

     

     

    If you want to modify the request method, the URI or the version, you should be able to use the individual HTTP:: commands to do so (HTTP::method, HTTP::uri, HTTP::version). I think this would actually be simpler if you're just trying to change the version of the request.

     

     

    Aaron

     

  •  

     

    Aaron,

     

     

    Thanks for the reply. My confusion now comes from the issue that after setting the URI, I get different responses from [HTTP::header POST] and [HTTP::uri].

     

     

    This code:

     

     

    if { $method equals "POST"} {

     

    log local0. "-----------POST-----------------"

     

    log local0. [HTTP::uri]

     

    log local0.[HTTP::method]

     

    log local0. [HTTP::header POST]

     

    log local0. [HTTP::version]

     

    log local0. "-----------POST-----------------"

     

    }

     

     

    Produces this log:

     

     

    Feb 20 21:53:17 tmm tmm[12387]: Rule IAJB : -----------POST-----------------

     

    Feb 20 21:53:17 tmm tmm[12387]: Rule IAJB : /siteminderagent/dmsforms/doLogin.fcc

     

    Feb 20 21:53:17 tmm tmm[12387]: Rule IAJB : POST

     

    Feb 20 21:53:17 tmm tmm[12387]: Rule IAJB : //stgws04.nyenet.state.ny.us/siteminderagent/dmsforms/doLogin.fcc HTTP/1.0

     

    Feb 20 21:53:17 tmm tmm[12387]: Rule IAJB : 1.1

     

    Feb 20 21:53:17 tmm tmm[12387]: Rule IAJB : -----------POST-----------------

     

     

     

  • Colin_Walker_12's avatar
    Colin_Walker_12
    Historic F5 Account
    Those responses look the same to me, save the fact that the POST header still contains the domain name and HTTP version. Other than that, those are the same URI requests, right?

     

     

    Colin
  • Again thanks for the reply.

     

     

    I'd like to remove the domain name from the post header. Posts without the F5 in the loop do not have the domain name in the Post hearder. I get a server error from the backside so I'd like to make everything as consistent as possible to isolate my problem.

     

     

    Cole

     

  • Hi Cole,

     

     

    When testing directly to the web server, do you see the full URL in the URI? ie, is the request formatted like this:

     

     

    POST http://example.com/path/to/file.ext HTTP/1.1

     

     

    Or is it like this?

     

     

    POST /path/to/file.ext HTTP/1.1

     

     

    What's it like when the BIG-IP is used?

     

     

    I wouldn't expect that BIG-IP would modify any of the HTTP content unless you're doing it explicitly in a rule.

     

     

    You can use LiveHttpHeaders for Firefox or IEwatch for IE to check the headers being sent and received on the client. You could also capture a tcpdump and review the headers received and sent by the BIG-IP.

     

     

    Regardless, RFC2616 on HTTP 1.1 states that servers must accept either format. Check this post for details on the RFC and/or removing the fully qualified portion of the URL in the URI (Click here).

     

     

    Aaron