开发者

Intermittent issue: POST requests getting corrupted

开发者 https://www.devze.com 2023-02-16 12:39 出处:网络
I\'ve been experiencing a weird intermittent issue over the last few months that I\'ve been going crazy trying to isolate.

I've been experiencing a weird intermittent issue over the last few months that I've been going crazy trying to isolate.

I have a Flash movie running on my site that generates XML data and then sends it via a POST request to a PHP script. The integrity of this file is key for the functioning of my application so I need to make sure that it arrives in tact. In order to this I generate a MD5 hash and send that along as well. On the receiving side my PHP script will accept the data, MD5 it up and compare the two hashes. If they are the same then I assume that the file is fine and store it for later use. If the MD5 hashes are different I send myself an e-mail and make a copy of the file for manual inspection.

Most times (>99%) this works beautifully and I find no issues with the uploaded data. However, every once in a while I find that that some additional characters are injected into the XML file which causes it to become corrupted. When this happens the file also appears to be truncated. Here's a snippet of what I'm seeing in the corrupted files - it appears as though it's some web server related setting:

... begin XML data ...

     <scale>1.7</scale>
     <rotation>0</rotation>
     <popdelay>0.7290036325342953</popdelay>
    Proxy-Connection: keep-alive
Cache-Control: max-age=0

0<poptime>0.6</poptime>
     <popangle>90</popangle>
     <shadowvis>true</shadowvis>
     <backingcolor>0xFF222222</backingcolor>

... continue XML data ...

I've found that the issue will continue to happen after it occurs on a particular machine -- i.e. if a user continually tries to upload their file the error will continue to crop up 100% of the time for them. I've seen this happen on multiple browsers / platforms (listed below):

Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10.5; en-US; rv:1.9.2.10) Gecko/20100914 Firefox/3.6.10
Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3

Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; CMNTDF; InfoPath.3; .NET4.0C)
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; InfoPath.1)
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.16) Gecko/20101130 Firefox/3.5.16 (.NET CLR 3.5.30729)
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; CMNTDF; InfoPath.3; .NET4.0C)

Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.3) Gecko/20100423 Ubuntu/10.04 (lucid) Firefox/3.6.3

My application server is being accessed via another apache2 server running mod_proxy, though I'm not sure if that is playing a role since this procedure seems to work almost all of the time on other machines. I've attempted to tune my apache2 settings but they don't seem to make any difference (I can post them later if you think it's 开发者_Python百科relevant / helpful)

If anyone has any idea what's going on or how to begin to address this I would really, really appreciate it. I've been trying to research this for a few months and haven't come up with anything.

Thank you so much for your time!


It looks like your proxy server is chunking the upload as the client didn't send a Content-Length header. http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#request-bodies

Try turning on proxy-sendcl which will force the proxy to buffer the upload to determine the content length, and stop chunking the upload as it hits your server.

0

精彩评论

暂无评论...
验证码 换一张
取 消