[Mongrel] Headers munged into RAW_POST_DATA

Jon Gubman jgubman at looksmart.net
Tue May 29 15:01:56 EDT 2007


Hi,
we're seeing a really weird problem in our production environment.  
"Connection: Keep-Alive\r\n" is being pre-pended to the  
RAW_POST_DATA, which makes requests error out. This bug is seen  
infrequently and *seems* to be browser-related, although I can't  
reproduce it using the browser reported in HTTP_USER_AGENT.

Set up is a hardware load balancer (NetScaler) -> mongrel_cluster  
0.2.1/mongrel 1.0

Has anyone else seen this or have any advice? I'm thinking I'll  
cobble together a kludge that inspects @head['RAW_POST_DATA'] and  
just sub out "Connection: Keep-Alive\r\n", but I'd really like to  
avoid doing that.


Here are two recent examples of the bug. Output is  
@request.env.keys.sort.each { |key| puts key: @request.env 
[key].to_s.strip }:

Parameters: {"ad"=>"5", "action"=>"new", "ct"=>nil,  
"controller"=>"ad_keywords", "Connection: Keep-Alive\r\nad_keyword"=> 
{"smart_keywords"=>"Non Emergency Transport \r\nNon Emergency  
Transportation\r\nTransportation for Disabled\r\nTransport for  
Disabled\r\nHandicap Transportation\r\nHandicap Transport\r 
\nDisability Transportation\r\nDisability Transport\r\nMedical  
Transportation Service\r\nMedical Transport Service\r\nMedical  
Transportation \r\nMedical Transport \r\nMedical Transportation Vans\r 
\nMedical Transport Vans\r\nMedical Patient Transportation \r 
\nMedical Patient Transport"}, "cid"=>"7"}
   * Rails root: /prod/amp/current


   * CONTENT_LENGTH          : 582
   * CONTENT_TYPE            : application/x-www-form-urlencoded
   * GATEWAY_INTERFACE       : CGI/1.2
   * HTTP_ACCEPT             : text/xml,application/xml,application/ 
xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
   * HTTP_ACCEPT_CHARSET     : ISO-8859-1,utf-8;q=0.7,*;q=0.7
   * HTTP_ACCEPT_ENCODING    : gzip,deflate
   * HTTP_ACCEPT_LANGUAGE    : en-us,en;q=0.5
   * HTTP_CONTENT_LENGTH     : 582
   * HTTP_CONTENT_TYPE       : application/x-www-form-urlencoded
   * HTTP_COOKIE             : accepting=1;
   * HTTP_HOST               : foo.com
   * HTTP_MAX_FORWARDS       : 10
   * HTTP_REFERER            : https://foo.com/ad_keywords/new? 
ad=5&cid=7
   * HTTP_USER_AGENT         : Mozilla/5.0 (Windows; U; Windows NT  
5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3
   * HTTP_VERSION            : HTTP/1.0
   * HTTP_X_BROWSER_TIMESTAMP: 386789
   * HTTP_X_FORWARDED_FOR    : xx.xxx.xxx.xxx
   * HTTP_X_FORWARDED_HOST   : foo.com
   * HTTP_X_FORWARDED_PROTO  : https
   * HTTP_X_FORWARDED_SERVER : foo.com
   * HTTP_X_NAVID            : f5c-50cfb
   * PATH_INFO               : /ad_keywords/new
   * QUERY_STRING            : cid=7&ad=5&ct=
   * RAW_POST_DATA           : Connection: Keep-Alive
   ad_keyword%5Bsmart_keywords%5D=Non+Emergency+Transport+%0D%0ANon 
+Emergency+Transportation%0D%0ATransportation+for+Disabled%0D% 
0ATransport+for+Disabled%0D%0AHandicap+Transportation%0D%0AHandicap 
+Transport%0D%0ADisability+Transportation%0D%0ADisability+Transport%0D 
%0AMedical+Transportation+Service%0D%0AMedical+Transport+Service%0D% 
0AMedical+Transportation+%0D%0AMedical+Transport+%0D%0AMedical 
+Transportation+Vans%0D%0AMedical+Transport+Vans%0D%0AMedical+Patient 
+Transportation+%0D%0AMedical+Patient+Transport%0D%0A&ad_keyword% 
5Bbroad_keywords%5D=
   * REMOTE_ADDR             : xx.xxx.xxx.xxx
   * REQUEST_METHOD          : POST
   * REQUEST_PATH            : /ad_keywords/new
   * REQUEST_URI             : /ad_keywords/new?cid=7&ad=5&ct=
   * SCRIPT_NAME             : /
   * SERVER_NAME             : foo.com
   * SERVER_PORT             : 80
   * SERVER_PROTOCOL         : HTTP/1.1
   * SERVER_SOFTWARE         : Mongrel 1.0





Parameters: {"Connection: Keep-Alive\r\ncoupon_code"=>"",  
"action"=>"deposit_funds", "controller"=>"accounts",  
"deposit_amount"=>""}

   * CONTENT_LENGTH         : 52
   * CONTENT_TYPE           : application/x-www-form-urlencoded
   * GATEWAY_INTERFACE      : CGI/1.2
   * HTTP_ACCEPT            : image/gif, image/x-xbitmap, image/jpeg,  
image/pjpeg, application/x-ms-application, application/vnd.ms- 
xpsdocument, application/xaml+xml, application/x-ms-xbap, application/ 
msword, application/vnd.ms-excel, application/vnd.ms-powerpoint,  
application/x-shockwave-flash, */*
   * HTTP_ACCEPT_ENCODING   : gzip, deflate
   * HTTP_ACCEPT_LANGUAGE   : en-us
   * HTTP_CACHE_CONTROL     : no-cache
   * HTTP_CONTENT_LENGTH    : 52
   * HTTP_CONTENT_TYPE      : application/x-www-form-urlencoded
   * HTTP_COOKIE            : accepting=1;
   * HTTP_HOST              : foo.com
   * HTTP_MAX_FORWARDS      : 10
   * HTTP_REFERER           : https://foo.com/accounts/deposit_funds? 
aid=6
   * HTTP_UA_CPU            : x86
   * HTTP_USER_AGENT        : Mozilla/4.0 (compatible; MSIE 7.0;  
Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET  
CLR 3.0.04506; .NET CLR 1.1.4322)
   * HTTP_VERSION           : HTTP/1.0
   * HTTP_X_FORWARDED_FOR   : xxx.xxx.xxx.xxx
   * HTTP_X_FORWARDED_HOST  : foo.com
   * HTTP_X_FORWARDED_PROTO : https
   * HTTP_X_FORWARDED_SERVER: foo.com
   * PATH_INFO              : /accounts/deposit_funds
   * RAW_POST_DATA          : Connection: Keep-Alive
   coupon_code=&deposit_amount=
   * REMOTE_ADDR            : xxx.xxx.xxx.xxx
   * REQUEST_METHOD         : POST
   * REQUEST_PATH           : /accounts/deposit_funds
   * REQUEST_URI            : /accounts/deposit_funds
   * SCRIPT_NAME            : /
   * SERVER_NAME            : foo.com
   * SERVER_PORT            : 80
   * SERVER_PROTOCOL        : HTTP/1.1
   * SERVER_SOFTWARE        : Mongrel 1.0


More information about the Mongrel-users mailing list