Created
March 7, 2015 07:44
-
-
Save demianbrecht/3fd60994eceeb3da8f13 to your computer and use it in GitHub Desktop.
chunked request tests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import cherrypy | |
from pprint import pprint | |
class Root: | |
@cherrypy.expose | |
def index(self): | |
pprint(cherrypy.request.headers) | |
print(cherrypy.request.body.read()) | |
return '' | |
if __name__ == '__main__': | |
cherrypy.quickstart(Root()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from http.client import HTTPConnection | |
def _compute_hash(data): | |
if data is None: | |
return { | |
'Trailer': 'foo', | |
} | |
c = HTTPConnection('localhost:8080') | |
c.on_chunked_data = _compute_hash | |
c.request('POST', '/', ('****' for _ in range(10))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import uwsgi | |
# uwsgi --http :8080 --wsgi-file uwsgi_chunked.py --http-raw-body | |
def application(env, start_response): | |
data = uwsgi.chunked_read() | |
while data: | |
print(data) | |
data = uwsgi.chunked_read() | |
start_response('200 OK', [('Content-Type', 'text/html')]) | |
return [b'Hello World'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import uwsgi | |
# uwsgi -s /tmp/uwsgi.sock --wsgi-file uwsgi_nginx_chunked.py --http-raw-body | |
def application(env, start_response): | |
print(env['wsgi.input'].read()) | |
from pprint import pprint | |
pprint(env) | |
start_response('200 OK', [('Content-Type', 'text/html')]) | |
return [b'Hello World'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment