1

I am using web.py to run a server. I need to get a request from a remote server, however, the request sends me a data with Chunked Transfer Coding.

I can use web.ctx.env['wsgi.input'].read(1000) to get the data. But this is not what I need since I don't know the length of the data (because it is chunked). But if I use web.ctx.env['wsgi.input'].read() the server would crash.

Can anybody tell me how to get the chunked data in a request?

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
liminche
  • 261
  • 1
  • 6
  • 13
  • >But if I use web.ctx.env['wsgi.input'].read() the server would crash. How was it crashing? Throwing an exception/which one? – rsaxvc Mar 01 '15 at 18:26

2 Answers2

1

Calling .read() will fetch the entire file into a string, which might be too large.

Based on: https://stackoverflow.com/a/10140333/1125660

while True: chunk = web.ctx.env['wsgi.input'].read(1000) if chunk == '': break process(chunk)

Community
  • 1
  • 1
rsaxvc
  • 1,675
  • 13
  • 20
-1

web.py runs CherryPy as the web server and it has support for handling requests with chunked transfer coding. Have you misread the documentation?

Jahaja
  • 3,222
  • 1
  • 20
  • 11