[Mongrel] pb when posting to an action "render_text body, :status => 400"

Arthur Pelicano elpelicano at gmail.com
Sun Jun 10 13:40:14 EDT 2007


I'm trying to do a little openid-server in rails.

I encounter a very strange problem for me, you can see all the story in the
openid mailing-list :


In short, the problem is :
 the server has to do a  "render_text body, :status => 400"  to respond to a
post from a consumer.  (this is from the openid server example)

This is working fine with webrick, but not in mongrel 1.0.1 on osx where the
consumer get :
Net::HTTPBadResponse: wrong status line: "HTTP/1.1 0 "

If someone wants to try, just make a rails app :
rails test
script/generate controller test index

and in the test_controller define the action 'index' like that :

class TestController < ApplicationController
  def index
    render_text "test", :status => 400

you can know test this with irb (supposing the server is running on port
3000) :
require 'uri'
require 'net/http'

url = "http://localhost:3000/test"
uri = URI.parse(url)
http = Net::HTTP.new(uri.host, uri.port)
resp = http.post(uri.request_uri,"test")
=> Net::HTTPBadResponse: wrong status line: "HTTP/1.1 0 "

if you do the same with webrick it works :
=> #<Net::HTTPOK 200 OK  readbody=true>

(I'm not sure webrick is right saying HTTP OK, when we asked to respond a
400 status, but it does not break the consumer client !)

I didn't find anything on this problem on google.
I'm a newbie in ruby and rails, and a total newbie with mongrel, so I hope
this is not trivial.
If it is, sorry for this mail !

Any help or suggestions would be much appreciated.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/mongrel-users/attachments/20070610/cb247c14/attachment.html 

More information about the Mongrel-users mailing list