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)
On Saturday, July 22, 2017 at 6:47:12 PM UTC-5, Steve Piercy wrote:
>
> Sure. You can get it from the WSGI environment:
>
> https://docs.pylonsproject.org/projects/webob/en/stable/reference.html#response-as-a-wsgi-application
>
>
> Or you can manually set attributes or headers in the response object.
> https://docs.pylonsproject.org/projects/webob/en/stable/api/response.html
>
> --steve
>
>
> On 7/22/17 at 4:15 PM, [email protected] <javascript:> pronounced:
>
> >The following example does not have the protocol info, e.g.
> >'HTTP/1.0'. Is there a way to add such info?
> >
> >$ cat main.py #!/usr/bin/env python
> ># vim: set noexpandtab tabstop=2 shiftwidth=2 softtabstop=-1
> fileencoding=utf-8:
> >
> >from webob import Response
> >res = Response()
> >print str(res)
> >
> >$ ./main.py 200 OK
> >Content-Type: text/html; charset=UTF-8
> >Content-Length: 0
> >
>
> ------------------------
> Steve Piercy, Soquel, CA
>
>
--
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/pylons-discuss/29b75c8e-93f4-4a4d-ab55-adee3ede20ab%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.