Here is what I have tried. I don't see how to get the protocol with str(). Would you please show me the example code? Thanks.
$ cat ./main.py
#!/usr/bin/env python
# vim: set noexpandtab tabstop=2 shiftwidth=2 softtabstop=-1 fileencoding=utf-8:
from webob import Request, Response
def my_app(environ, start_response):
req = Request(environ)
res = Response()
res.content_type = 'text/plain'
parts = []
for name, value in sorted(req.environ.items()):
parts.append('%s: %r' % (name, value))
res.body = '\n'.join(parts)
return res(environ, start_response)
req = Request.blank('/')
res = req.get_response(my_app)
print res
$ ./main.py
200 OK
Content-Type: text/plain; charset=UTF-8
Content-Length: 390
HTTP_HOST: 'localhost:80'
PATH_INFO: '/'
QUERY_STRING: ''
REQUEST_METHOD: 'GET'
SCRIPT_NAME: ''
SERVER_NAME: 'localhost'
SERVER_PORT: '80'
SERVER_PROTOCOL: 'HTTP/1.0'
wsgi.errors: <open file '<stderr>', mode 'w' at 0x1006ea1e0>
wsgi.input: <_io.BytesIO object at 0x100803ad0>
wsgi.multiprocess: False
wsgi.multithread: False
wsgi.run_once: False
wsgi.url_scheme: 'http'
wsgi.version: (1, 0)