[Web-SIG] environ["wsgi.input"].read()

Brian Smith brian at briansmith.org
Fri Jan 25 16:04:37 CET 2008


1. PEP 333 doesn't indicate that the size parameter for the read() method is optional. Is it optional or required? If it is optional, is the default value -1?

2. What are the semantics of environ["wsgi.input"].read(-1) when Content-Length is provided? Is it guaranteed to return the entire request entity, up to at most <Content-Length> bytes?

3. What are the semantics of environ["wsgi.input"].read(-1) when the response has no Content-Length? Can environ["wsgi.input"].read(-1) be used (as the only available mechanism) to read a chunked response entity?

Putting all this together, are these two programs correct?:

def application(environ, start_response):
	start_response("200 OK", [])
	yield environ["wsgi.input"].read()

def application(environ, start_response):
	start_response("200 OK", [])
	yield environ["wsgi.input"].read(-1)

This is another issue where there is a lot of variance between gateways, where I think a clarification in the specification is needed.

- Brian



More information about the Web-SIG mailing list