Re: [modwsgi] mod_wsgi chunked encoded request

301 views
Skip to first unread message

Graham Dumpleton

unread,
Oct 19, 2012, 10:43:35 PM10/19/12
to mod...@googlegroups.com
The WSGI specification doesn't support chunked request content. I am
presuming therefore that to get something working when using
WSGIChunkedRequest, that you would need to have modified web.py in a
way that allowed it to work. Have you done anything like that?

If you don't then web.py will likely pass through an empty string for
the request content, which seems to be what that error is indicating
that elementtree found.

Graham

On 19 October 2012 22:01, Aashish Pathak <aashish...@gmail.com> wrote:
> I have deployed my web.py application on Apachev2.2 with mod_wsgiv3.4.
> The web.py application accepts the requests from third party which are
> chunked transfer encoded.
> I have enabled chunked encoded requests with the help of
> 'WSGIChunkedRequest' directive.
>
> Now, i am facing something streaming related issue,
> here is the traceback,
> ---
> Traceback (most recent call last):
> File
> "/usr/local/lib/python2.6/dist-packages/web.py-0.36-py2.6.egg/web/application.py",
> line 237, in process
> return self.handle()
> File
> "/usr/local/lib/python2.6/dist-packages/web.py-0.36-py2.6.egg/web/application.py",
> line 228, in handle
> return self._delegate(fn, self.fvars, args)
> File
> "/usr/local/lib/python2.6/dist-packages/web.py-0.36-py2.6.egg/web/application.py",
> line 409, in _delegate
> return handle_class(cls)
> File
> "/usr/local/lib/python2.6/dist-packages/web.py-0.36-py2.6.egg/web/application.py",
> line 385, in handle_class
> return tocall(*args)
> File "/var/www/egauge/server.py", line 67, in POST
> data = parse(web.data(), excluded=inactive_meters)
> File "/home/ubuntu/plotwatt/readings_servers/egauge/egauge_parser.py", line
> 27, in parse
> logging.warn(xml)
> File
> "/usr/local/lib/python2.6/dist-packages/elementtree-1.2.7_20070827_preview-py2.6.egg/elementtree/ElementTree.py",
> line 1012, in XML
> return api.fromstring(text)
> File
> "/usr/local/lib/python2.6/dist-packages/elementtree-1.2.7_20070827_preview-py2.6.egg/elementtree/ElementTree.py",
> line 183, in fromstring
> return parser.close()
> File
> "/usr/local/lib/python2.6/dist-packages/elementtree-1.2.7_20070827_preview-py2.6.egg/elementtree/ElementTree.py",
> line 1301, in close
> self._parser.Parse("", 1) # end of data
> ExpatError: no element found: line 1, column 0
> ---
>
> I have seen some work arounds for Django application here,
> http://stackoverflow.com/questions/12091067/handling-http-chunked-encoding-with-django
>
> Is there anything similar i can do with web.py as well ?
>
> --
> You received this message because you are subscribed to the Google Groups
> "modwsgi" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/modwsgi/-/PffmdxE7cFgJ.
> To post to this group, send email to mod...@googlegroups.com.
> To unsubscribe from this group, send email to
> modwsgi+u...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/modwsgi?hl=en.

Aashish Pathak

unread,
Oct 20, 2012, 8:09:16 AM10/20/12
to mod...@googlegroups.com
Yes, you are right. I will need to modify web.py itself.
I have not modified the web.py yet.
Does anybody her have worked on such case?

Graham Dumpleton

unread,
Oct 21, 2012, 12:30:35 AM10/21/12
to mod...@googlegroups.com
The other alternative is that you write a WSGI middleware that wraps
web.py and which reads all the request content from a chunked request,
ignore the WSGI rules about CONTENT_LENGTH, and then recalculates
CONTENT_LENGTH and sets it so that web.py will read that.

Size of request content can be an issue because if you read it all
into memory, then could blow out memory usage. So, for these special
cases maybe write to a file and then use that as the input.

Graham
> https://groups.google.com/d/msg/modwsgi/-/-elWrOaw8ioJ.
Reply all
Reply to author
Forward
0 new messages