Re: Avoid hangs when handling of HTTP POST requests

will guaraldi <[email protected]>
Newsgroups gmane.comp.web.pyblosxom.devel
Message-ID <[email protected]>
Sorry it took so long.  I've applied this patch (I fixed the patch below 
so it matches the follow-up email you sent fixing the patch--figured I'd 
reply to this email since it has all the information in it) to the code 
base so that we now look at the content length for post requests and read 
that much data rather than reading to the next EOF.

Thanks!  Sorry it took so long.

/will


On Sun, 9 Oct 2005, Kaloian Doganov wrote:
> 
> I am using PyBlosxom with bozohttpd [1] -- a small and featureless HTTP
> server launched from inetd.  When serving requests to CGI scripts,
> bozohttpd does not send EOF at the end of the body.  Although
> inconvenient, this behaviour is compliant to CGI 1.1 specification [2]:
>
>    The server will send CONTENT_LENGTH bytes on this file
>    descriptor. Remember that it will give the CONTENT_TYPE of the data
>    as well. The server is in no way obligated to send end-of-file after
>    the script reads CONTENT_LENGTH bytes.
>
> This causes PyBlosxom to hang when serving POST requests (very common
> when comments plugin is used).  This is the same problem described in
> bug #1184799 [3], just experienced with different HTTP server --
> bozohttpd instead of Twisted.
>
>
> [1] http://www.eterna.com.au/bozohttpd/
> [2] http://hoohoo.ncsa.uiuc.edu/cgi/in.html
> [3] http://sourceforge.net/tracker/index.php?func=detail&aid=1184799&group_id=67445&atid=517918
>
> So, I suggest the following patch:
>
> Index: pyblosxom.py
> ===================================================================
> RCS file: /cvsroot/pyblosxom/pyblosxom/Pyblosxom/pyblosxom.py,v
> retrieving revision 1.72
> diff -U3 -r1.72 pyblosxom.py
> --- pyblosxom.py        7 Oct 2005 22:48:32 -0000       1.72
> +++ pyblosxom.py        8 Oct 2005 23:56:43 -0000
> @@ -448,12 +448,13 @@
>         pyhttp = self.getHttp()
>         input = pyhttp['wsgi.input']
>         method = pyhttp["REQUEST_METHOD"]
> +        length = int(pyhttp["CONTENT_LENGTH"])
>
>         # there's no data on stdin for a GET request.  pyblosxom
>         # will block indefinitely on the read for a GET request with
>         # thttpd.
>         if method != "GET":
> -            self._in.write(input.read())
> +            self._in.write(input.read(length))
>             # rewind to start
>             self._in.seek(0)


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.