Empty CGI stdinput

6 views
Skip to first unread message

Cyrille

unread,
Sep 17, 2009, 12:29:06 AM9/17/09
to Phusion Passenger Discussions
Hi guys,

I am using a CGI hack to make SwfUpload work with Rails 2.2.1.

The hack I use is described here:

http://swfupload.org/forum/generaldiscussion/1202

It works fine locally with Webrick, but on my staging server (running
passenger 2.2.5), it fails because the CGI stdinput is empty...

To be more descriptive, in the code (http://gist.github.com/55772) on
line 14, if I output @session.cgi.stdinput, I get an empty string on
my staging server.

On my local machine, I get the uploaded data with my session cookie at
the end (as expected).

I am confused: why would the standard input be empty?? Where do I go
from there? How could I debug what is going on?

Any suggestion welcome.

Cyrille

Hongli Lai

unread,
Sep 17, 2009, 3:28:30 AM9/17/09
to phusion-...@googlegroups.com

I'm not sure. Can you check whether @session.cgi is of class
PhusionPassenger::Railz::CGIFixed?

--
Phusion | The Computer Science Company

Web: http://www.phusion.nl/
E-mail: in...@phusion.nl
Chamber of commerce no: 08173483 (The Netherlands)

Cyrille

unread,
Sep 17, 2009, 5:14:56 AM9/17/09
to Phusion Passenger Discussions
Hi there,

Yes it is. And @session.cgi.stdinput is of class UNIXSocket.

If I check @session.cgi.stdinput.eof? it says true.

So apparently the socket is closed... Is that expected?
Is it possible that the socket content has already been read? If so,
is there a way I can access the request body?

Cheers

Cyrille

On Sep 17, 7:28 pm, Hongli Lai <hon...@phusion.nl> wrote:
> On Thu, Sep 17, 2009 at 6:29 AM, Cyrille <cbonne...@gmail.com> wrote:
>
> > Hi guys,
>
> > I am using a CGI hack to make SwfUpload work with Rails 2.2.1.
>
> > The hack I use is described here:
>
> >http://swfupload.org/forum/generaldiscussion/1202
>
> > It works fine locally with Webrick, but on my staging server (running
> > passenger 2.2.5), it fails because the CGI stdinput is empty...
>
> > To be more descriptive, in the code (http://gist.github.com/55772) on
> > line 14, if I output @session.cgi.stdinput, I get an empty string on
> > my staging server.
>
> > On my local machine, I get the uploaded data with my session cookie at
> > the end (as expected).
>
> > I am confused: why would the standard input be empty?? Where do I go
> > from there? How could I debug what is going on?
>
> > Any suggestion welcome.
>
> I'm not sure. Can you check whether @session.cgi is of class
> PhusionPassenger::Railz::CGIFixed?
>
> --
> Phusion | The Computer Science Company
>
> Web:http://www.phusion.nl/
> E-mail: i...@phusion.nl

Hongli Lai

unread,
Sep 17, 2009, 6:21:04 AM9/17/09
to phusion-...@googlegroups.com
On Thu, Sep 17, 2009 at 11:14 AM, Cyrille <cbon...@gmail.com> wrote:
>
> Hi there,
>
> Yes it is. And @session.cgi.stdinput is of class UNIXSocket.
>
> If I check @session.cgi.stdinput.eof? it says true.
>
> So apparently the socket is closed... Is that expected?
> Is it possible that the socket content has already been read? If so,
> is there a way I can access the request body?

Yes, the socket is closed and its contents has probably already been
read by Rails. If you can access the Rails request object you can
extract the parameters from there.

--
Phusion | The Computer Science Company

Web: http://www.phusion.nl/
E-mail: in...@phusion.nl

Cyrille

unread,
Sep 20, 2009, 8:12:06 PM9/20/09
to Phusion Passenger Discussions
Hi,

thanks for your reply.

I just wanted to point out how I fixed it, in case it helps someone
else:

in the cookie_store, I only have access to the @session object, so to
keep the hack confined there, I had to use the query string instead,
like so:

cookie_name = @cookie_options["name"]
reg = %r{#{cookie_name}=(.+)}
md = reg.match @session.cgi.env_table["QUERY_STRING"]
if md
cookie = md[1]
else
reg = %r{#{cookie_name}=(.+)&}
md = reg.match @session.cgi.env_table["QUERY_STRING"]
if md
cookie = md[1]
end
end

Ugly, but it works.

Cheers

Cyrille

On Sep 17, 10:21 pm, Hongli Lai <hon...@phusion.nl> wrote:
> On Thu, Sep 17, 2009 at 11:14 AM, Cyrille <cbonne...@gmail.com> wrote:
>
> > Hi there,
>
> > Yes it is. And @session.cgi.stdinput is of class UNIXSocket.
>
> > If I check @session.cgi.stdinput.eof? it says true.
>
> > So apparently the socket is closed... Is that expected?
> > Is it possible that the socket content has already been read? If so,
> > is there a way I can access the request body?
>
> Yes, the socket is closed and its contents has probably already been
> read by Rails. If you can access the Rails request object you can
> extract the parameters from there.
>
> --
> Phusion | The Computer Science Company
>
> Web:http://www.phusion.nl/
> E-mail: i...@phusion.nl
Reply all
Reply to author
Forward
0 new messages