Forum Discussion

yuce_sungur_100's avatar
yuce_sungur_100
Icon for Nimbostratus rankNimbostratus
Mar 03, 2010

iRule transforms from raw socket to HTTP POST,

I have been working on a project that transofrms raw socket to HTTP POST requests.It has been working nice until a huge packet arrives.My irule is succesfully merges all the tcp packets and send them to backend in a POST body but "Content-length" header of the HTTP request seems to be miscalculated.

 

relevant iRule lines are;

 

 

append veri "\r\nContent-Length: "

 

append veri [TCP::payload length]

 

"

 

 

any idea to correct the issue?

 

 

TCP::payload length must give the final length of the two merged packets.
  • hoolio's avatar
    hoolio
    Icon for Cirrostratus rankCirrostratus
    You'd need to calculate the number of bytes in the HTTP payload for the HTTP content-length header--not the length of the TCP payload. You could try subtracting the length of the HTTP headers from the TCP payload size, or just parse the TCP for the length of the HTTP payload.

     

     

    If you want more specific suggestions, could you post the iRule and relevant logs showing the issue?

     

     

    Thanks,

     

    Aaron
  • the problem occurs during the transformation from raw socket data to http data.if the input data is two packet length, my irule is correctly placing headers,creates three packets from 2 packets.The content is correct but the content-length value is equal to the length of only the first packet payload.Somehow irule can sense the two packets need to be chunked but it miscalculates the length of the payload.

     

    I dont have any special log, but I can provide you pcap files , that shows both input and output of the iRule.

     

    I am afraid it is a bug issue about iRule, and is not gonna work ,where my project is ready for production except for the large packets.

     

     

    you cna directly get in contact with me.

     

     

    thanks

     

     

  • hoolio's avatar
    hoolio
    Icon for Cirrostratus rankCirrostratus
    Hi Ysungur,

     

     

    I don't have any way to view your contact info and I'm a bit swamped these days. If you'd like me and others to provide more detailed suggestions, you could try adding some debug logging to the iRule, reproduce the issue, post the iRule you're testing and the debug log output.

     

     

    Else, you could try opening a case with F5 Support if you think the iRule functionality isn't working correctly.

     

     

    In concept though, I'd think you need to set the Content-Length header in the request to the actual HTTP payload length. I don't think this would be the same as the TCP payload length, as the TCP payload would contain both HTTP headers and HTTP payload.

     

     

    If the HTTP payload you're forming is in multiple TCP packets, I'd think you'd need to continue collecting the TCP payload until you have the full data you want to insert as the HTTP payload.

     

     

    Aaron
  • Is there anyway to catch PSH flag in client packet, or CLIENT_DATA simply exits when there is push in the request