rack-devel archive mirror (unofficial) https://groups.google.com/group/rack-devel
 help / color / mirror / Atom feed
* [FIX] POST requests throws an exception in CGI mode
@ 2010-09-03 13:34 ybart
  0 siblings, 0 replies; only message in thread
From: ybart @ 2010-09-03 13:34 UTC (permalink / raw)
  To: Rack Development

I have configured a lighttpd to run a sinatra application running in
CGI mode. I tested against rack 1.2.0 because 1.2.1 does not run
aggainst Ruby 1.8.6

It work fine with GET requests but fails for POST requests throwing
the following exception:

Rack::Lint::LintError: rack.input#rewind raised Errno::ESPIPE
	/usr/lib/ruby/gems/1.8/gems/rack-1.2.0/lib/rack/lint.rb:19:in
`assert'
	/usr/lib/ruby/gems/1.8/gems/rack-1.2.0/lib/rack/lint.rb:363:in
`rewind'
	/usr/lib/ruby/gems/1.8/gems/rack-1.2.0/lib/rack/request.rb:157:in
`POST'
	/usr/lib/ruby/gems/1.8/gems/rack-1.2.0/lib/rack/methodoverride.rb:
15:in `call'
	/usr/lib/ruby/gems/1.8/gems/rack-1.2.0/lib/rack/commonlogger.rb:18:in
`call'
	/usr/lib/ruby/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:979:in
`call'
	/usr/lib/ruby/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:1005:in
`synchronize'
	/usr/lib/ruby/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:979:in
`call'
	/usr/lib/ruby/gems/1.8/gems/rack-1.2.0/lib/rack/lint.rb:48:in `_call'
	/usr/lib/ruby/gems/1.8/gems/rack-1.2.0/lib/rack/lint.rb:36:in `call'
	/usr/lib/ruby/gems/1.8/gems/rack-1.2.0/lib/rack/showexceptions.rb:
24:in `call'
	/usr/lib/ruby/gems/1.8/gems/rack-1.2.0/lib/rack/content_length.rb:
13:in `call'
	/usr/lib/ruby/gems/1.8/gems/rack-1.2.0/lib/rack/handler/cgi.rb:34:in
`serve'
	/usr/lib/ruby/gems/1.8/gems/rack-1.2.0/lib/rack/handler/cgi.rb:8:in
`run'
	/usr/lib/ruby/gems/1.8/gems/rack-1.2.0/lib/rack/server.rb:213:in
`start'
	/usr/lib/ruby/gems/1.8/gems/rack-1.2.0/lib/rack/server.rb:100:in
`start'
	/usr/lib/ruby/gems/1.8/gems/rack-1.2.0/bin/rackup:4
	/usr/bin/rackup:19:in `load'
	/usr/bin/rackup:19

According to what I've read while Googling about this problem, is that
rewind does not work in CGI mode.

The documentation for rewind indicates the following:

## * +rewind+ must be called without arguments. It rewinds the input
      ##   stream back to the beginning. It must not raise
Errno::ESPIPE:
      ##   that is, it may not be a pipe or a socket. Therefore,
handler
      ##   developers must buffer the input data into some rewindable
object
      ##   if the underlying input stream is not rewindable.

I've applied the following change indicated at:
http://d.hatena.ne.jp/gnarl/20090924/1253777224

It seems to work, so it might useful to commit this change for future
releases.

Thanks,
Yvan

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2010-09-03 15:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-03 13:34 [FIX] POST requests throws an exception in CGI mode ybart

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).