0

I have my web.py application running. It receives POST request from outside. The request header contains transfer-encoding: chunked. When i try to read the data with web.data() the process starts consuming enormous amount of memory and after couple of minutes server dies.

I have a doubt of this transfer-encoding type. Does anyone faced same kinda issue?

Alexxio
  • 1,091
  • 3
  • 16
  • 38
Aashish P
  • 1,894
  • 5
  • 22
  • 36

1 Answers1

0

Actually, this is because just a few web server considered request have a body with chunk. SimpleHTTPServer inside python will crush in this situation. tornado is OK, but can't get body with wsgi.input. gevent is fine, but webpy don't process right. You can fix this problem with those code.

def data():
    if 'data' not in ctx:
        if ctx.env.get('HTTP_TRANSFER_ENCODING') == 'chunked':
            ctx.data = ctx.env['wsgi.input'].read()
        else:
            cl = intget(ctx.env.get('CONTENT_LENGTH'), 0)
            ctx.data = ctx.env['wsgi.input'].read(cl)
    return ctx.data

Of cause, you should use those code with gevent.