Greetings all, highly enjoying teaching myself Ruby and RoR, but hit a little snag tonight and wanted to ask for some clarification. I created simple, single-table, scaffolded app for a Person class. Using the update form worked fine, but I did this to help create a little XMLHTTPRequest library. Here''s a Javascript snippet: req.open("POST", "/contacts/update", true); req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); req.send(id="N"&var1="foo"&var2="blah"); Whenever I would execute this POST, the apache logs would indicate an error 500 response code, and the following in the error log: /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.4.0/lib/action_controller/cgi_ext/raw_post_data_fix.rb:40:in `[]='': bad environment variable value (ArgumentError) from /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.4.0/lib/action_controller/cgi_ext/raw_post_data_fix.rb:40:in `read_query_params'' from /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.4.0/lib/action_controller/cgi_ext/raw_post_data_fix.rb:14:in `initialize_query'' from /usr/local/lib/ruby/1.8/cgi.rb:2269:in `initialize'' from /usr/local/lib/ruby/gems/1.8/gems/rails-0.9.5/lib/dispatcher.rb:28:in `new'' from /usr/local/lib/ruby/gems/1.8/gems/rails-0.9.5/lib/dispatcher.rb:28:in `dispatch'' from /Users/wismar/dev/ruby/uc/public/dispatch.cgi:10 [Wed Feb 9 03:43:03 2005] [error] [client 127.0.0.1] Premature end of script headers: /Users/wismar/dev/ruby/uc/public/dispatch.cgi Am I missing a required header on the request somewhere? I ended up hacking my way around it by changing line 40 in raw_post_data_fix.rb from "env_table[''RAW_POST_DATA''] = content.freeze" to "content.freeze". Obviously, that''s not a healthy long-term solution. Any suggestions would be greatly appreciated. Using rails 0.9.5, ruby 1.8.2, and built in apache on OS X. Thanks, Andy Wismar
> Here''s a Javascript snippet: > req.open("POST", "/contacts/update", true); > req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); > req.send(id="N"&var1="foo"&var2="blah");Shouldn''t this be req.send("id=''N''&var1=''foo''&var2=''blah''"). In other words, did you quote the GET string improperly? -- Mando> > Whenever I would execute this POST, the apache logs would indicate an > error 500 response code, and the following in the error log: > > /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.4.0/lib/action_controller/cgi_ext/raw_post_data_fix.rb:40:in > `[]='': bad environment variable value (ArgumentError) > from /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.4.0/lib/action_controller/cgi_ext/raw_post_data_fix.rb:40:in > `read_query_params'' > from /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.4.0/lib/action_controller/cgi_ext/raw_post_data_fix.rb:14:in > `initialize_query'' > from /usr/local/lib/ruby/1.8/cgi.rb:2269:in `initialize'' > from /usr/local/lib/ruby/gems/1.8/gems/rails-0.9.5/lib/dispatcher.rb:28:in > `new'' > from /usr/local/lib/ruby/gems/1.8/gems/rails-0.9.5/lib/dispatcher.rb:28:in > `dispatch'' > from /Users/wismar/dev/ruby/uc/public/dispatch.cgi:10 > [Wed Feb 9 03:43:03 2005] [error] [client 127.0.0.1] Premature end of > script headers: /Users/wismar/dev/ruby/uc/public/dispatch.cgi > > Am I missing a required header on the request somewhere? I ended up > hacking my way around it by changing line 40 in raw_post_data_fix.rb > from "env_table[''RAW_POST_DATA''] = content.freeze" to > "content.freeze". Obviously, that''s not a healthy long-term solution. > > Any suggestions would be greatly appreciated. Using rails 0.9.5, ruby > 1.8.2, and built in apache on OS X. > > Thanks, > Andy Wismar > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
> > Here''s a Javascript snippet: > > req.open("POST", "/contacts/update", true); > > req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); > > req.send(id="N"&var1="foo"&var2="blah"); > > Shouldn''t this be req.send("id=''N''&var1=''foo''&var2=''blah''"). In other > words, did you quote the GET string improperly? >I noticed that as soon as I posted, that was just me typing in the string improperly instead of cutting & pasting. The actual query string is created in a loop, with no quotes at all, like var1=val1&var2=val2.... So I didn''t have a nice example to cut & paste. I also made sure that I didn''t have any obscure characters or anthing in the vars & values, just standard alpha characters.