The result of trying this code:
Traceback (most recent call last):
File "/usr/lib64/python2.6/site-packages/mod_python/importer.py",
line 1537, in HandlerDispatch
default=default_handler, arg=req, silent=hlist.silent)
File "/usr/lib64/python2.6/site-packages/mod_python/importer.py",
line 1229, in _process_target
result = _execute_target(config, req, object, arg)
File "/usr/lib64/python2.6/site-packages/mod_python/importer.py",
line 1128, in _execute_target
result = object(arg)
File "/usr/lib64/python2.6/wsgiref/modpython_gateway.py", line 205,
in handler
module = __import__(modname, globals(), locals(), [''])
File "/www/path/service/serverw.py", line 10, in <module>
web.header('Content-Type', 'text/plain')
File "/usr/local/lib/python2.6/site-packages/web/webapi.py", line
222, in header
ctx.headers.append((hdr, value))
AttributeError: 'ThreadedDict' object has no attribute 'headers'
On 9 Feb., 04:19, Ben Corneau <[email protected]> wrote:
> You can access the headers using web.ctx.envrion. Your headers will be
> an item in the envrion dict prepended with "HTTP_" and converted to
> upper case.
> I'm not familiar with modpython_gateway.py and don't know if it will
> change this behavior.
>
> example request (I've recently discovered
> requests,http://docs.python-requests.org/en/latest/index.html. It's awesome!)
> ---------------------------------
> import requests
> requests.get("http://127.0.0.1:8080/resource",
> headers={"auth_token":"xxxxxxxxxxx"})
>
> web.py code
> ---------------------------
> def GET(self):
> auth_token = web.ctx.environ["HTTP_AUTH_TOKEN"]
>
> On Feb 8, 6:22 am, mvl <[email protected]> wrote:
>
>
>
>
>
>
>
> > Hello,
>
> > I'am searching for a way to authenticate against the api that I have
> > written with web.py.
>
> > I thought about something like a API-Key/Token that would be included
> > in the HTTP headers of the request.
>
> > How can I get a specific HTTP-Header with web.py? I'am using
> > modpython_gateway.py/mod_python in my production environment.
>
> > I have seen the method web.header() - but it seems like that this
> > method is only for setting specific response-headers.
--
You received this message because you are subscribed to the Google Groups
"web.py" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/webpy?hl=en.