Forum Discussion

Rostislav_Zatol's avatar
Rostislav_Zatol
Icon for Nimbostratus rankNimbostratus
Apr 02, 2010

unchanking and collecting whole POST body

Hi,

 

 

I am going crazy trying to collect complete POST body sent in chunked format to the server.

 

 

HTTP::collect requires a number of bytes to collect, chunked http messages doese not have content-length header, so I dont see a possibility to collect whole body.

 

 

Chunked format has byte count for following body part. i.e.

 

 

-----

 

POST /xyz HTTP 1.1

 

header 1

 

header 2

 

Transfer-Encoding: chunked

 

 

28

 

herebodypartwith13characters

 

 

0

 

--------

 

the shows that 28 bytes of body follows.

 

 

I was trying to call [HTTP::payload length], it delivers 4, that means it should be 280d0a, but [HTTP::payload] itself delivers 0

 

 

I have tried to call [HTTP::collect [HTTP::payload]] doese not work also, also [HTTP::collect [HTTP::payload length]].

 

 

Maybe I am just stupid, but is there no standard parsing mechanism for HTTP 1.1 chunked POST requests?

 

 

BR

 

RZ

4 Replies

  • A fairly common technique here is to specify a maximum collection value of 1MB. The description section of HTTP::collect in the iRules Wiki discusses this, as you know, there are a few nuances you'll need to be aware of!

     

    http://devcentral.f5.com/wiki/default.aspx/iRules/HTTP__collect.html

     

     

    -Matt
  • But specifying 1MB collection value will never trigger HTTP_REQUEST_DATA in which I need to analyze the content.

     

     

    Is there a way to set some timeout for collecting data? lets say max 1sec?

     

    or some other event?
  • Is there a way for you to configure/change the client to not send chunked requests?

     

     

    The only option I can think to handle chunked request payloads in an iRule if the client can reuse the TCP connection is to collect the TCP payload and parse the chunks using TCP::payload. The logic is described in RFC2616:

     

     

    http://tools.ietf.org/html/rfc2616section-3.6.1

     

    and appendix 19.4.6:

     

    19.4.6 Introduction of Transfer-Encoding

     

     

    Anyone else have ideas on this?

     

     

    Aaron
  • Hi,

     

     

    Look at this iRule - I have got it working;-

     

     

    http://devcentral.f5.com/wiki/iRules.HTTP%20Request%20Unchunker.ashx

     

     

    Joanna