#3619 closed defect (fixed)
using req.environ[wsgi.input].read() makes tracd connection stall
Reported by: | Owned by: | Matthew Good | |
---|---|---|---|
Priority: | normal | Milestone: | 0.10 |
Component: | web frontend/tracd | Version: | devel |
Severity: | normal | Keywords: | needinfo |
Cc: | trac@… | Branch: | |
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description
When I run tracd and attempt to access a URI whose handler uses Request.environ['wsgi.input'].read()
, that connection hangs until I cancel it. Attached is a testcase plugin and output log.
Attachments (3)
Change History (10)
by , 18 years ago
by , 18 years ago
Attachment: | trac-wsgi.input-testcase.tar.bz2 added |
---|
testcase plugin source code; tested using r3640
follow-up: 2 comment:1 by , 18 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
Replying to trac@lazymalevolence.com:
When I run tracd and attempt to access a URI whose handler uses
Request.environ['wsgi.input'].read()
, that connection hangs until I cancel it. Attached is a testcase plugin and output log.
During the initialization of the Request
object all the content of wsgi.input
is read, so there will be nothing left to read in the request handler. For help developing a plugin check on the MailingList, since reading from wsgi.input
is not the right way to get the data you need.
follow-up: 3 comment:2 by , 18 years ago
Resolution: | invalid |
---|---|
Status: | closed → reopened |
Replying to mgood:
Replying to trac@lazymalevolence.com:
When I run tracd and attempt to access a URI whose handler uses
Request.environ['wsgi.input'].read()
, that connection hangs until I cancel it. Attached is a testcase plugin and output log.During the initialization of the
Request
object all the content ofwsgi.input
is read, so there will be nothing left to read in the request handler. For help developing a plugin check on the MailingList, since reading fromwsgi.input
is not the right way to get the data you need.
Firstly, based on reading the code in trac/web/api.py
, it seems that the content of wsgi.input
is read only if the Content-Type indicates that it is form data. I have been testing it when it is not either of those types. Secondly, I neglected to mention (i.e., forgot) that it works just fine when using a mod_python
setup. In any case, the behavior of wsgi.input
is inconsistent between web frontends, and this, at least, deserves to be looked at.
comment:3 by , 18 years ago
Keywords: | needinfo added |
---|
Replying to trac@lazymalevolence.com:
Secondly, I neglected to mention (i.e., forgot) that it works just fine when using a
mod_python
setup. In any case, the behavior ofwsgi.input
is inconsistent between web frontends, and this, at least, deserves to be looked at.
Ah, yes I think that was necessary at least for the XML-RPC plugin to read the request body. Have you tried using req.read()
? This will read from wsgi.input
, but checks the "Content-Length" header for how many bytes to read.
comment:4 by , 18 years ago
Cc: | added |
---|
This is what happens when I change the last line in my testcase from req.write(req.environ['wsgi.input'].read())
to req.write(req.read())
and attempt to access /null/testcase
in the same fashion (still r3640):
2006-08-25 14:19:56,800 Trac[main] ERROR: get_header() takes exactly 2 arguments (3 given) Traceback (most recent call last): File "/usr/lib/python2.4/site-packages/trac/web/main.py", line 335, in dispatch_request dispatcher.dispatch(req) File "/usr/lib/python2.4/site-packages/trac/web/main.py", line 220, in dispatch resp = chosen_handler.process_request(req) File "build/bdist.linux-i686/egg/wsgi_input_testcase/__init__.py", line 12, in process_request # ;-) File "/usr/lib/python2.4/site-packages/trac/web/api.py", line 411, in read size = int(self.get_header('Content-Length', -1)) TypeError: get_header() takes exactly 2 arguments (3 given)
I assume that when Request.read()
was written, Request.get_header()
had a method signature similar to dict().get()
.
by , 18 years ago
Attachment: | request_read_fix.patch added |
---|
fixes the call to get_header() in Request.read()
comment:7 by , 18 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Ok, a small variant on that patch has been committed in r3746 along with unit tests.
command line output + tracd log output