Subject: | PUT method with empty body seems to freeze CGI->new() |
A PUT HTTP request with no body and no Content-Length or Content-Type
headers seems to freeze up CGI->new(). I found this while trying to
install Test::WWW::Mechanize, whose t/put_ok.t script fails under CGI
versions 3.44, 3.45, and 3.48. 3.43 works fine, as does 3.29; I haven't
tested any others.
Steps to reproduce:
1. install CGI 3.44 or later
2. get Test::WWW::Mechanize (I'm using 1.24 but I don't think it matters)
3. unpack T::WWW::M
4. in the T::WWW::M directory, call "perl Makefile.PL" and "make" to set
up the blib/ directory
5. in the T::WWW::M directory, call "prove -bv t/put_ok.t". The HTTP PUT
requests will time out.
I have narrowed the path of execution down to this:
* T::WWW::M's test t/put_ok.t calls the testserver in t/TestServer.pm
* TestServer subclasses HTTP::Server::Simple::CGI
* The method HTTP::Server::Simple::CGI::handler calls CGI->new()
* CGI->new() calls CGI->init()
* CGI->init() calls CGI->read_from_stdin() around line 651
* CGI->read_from_stdin() never returns
It's difficult to say that this is invalid behaviour, since the utility
of an empty PUT request is questionable. However there's nothing in the
RFC I can see which explicitly forbids an empty PUT request, and if
there's no Content-Length header then it's certainly possible that
there's no body to the HTTP request.
In any case, even if you think an empty HTTP PUT request is invalid, CGI
should probably fail gracefully rather than getting stuck.
I had previously raised this issue with T::WWW::M before finding out
that CGI is probably responsible. The previous discussion can be viewed
here:
http://code.google.com/p/www-mechanize/issues/detail?id=127