Documentation for pulsar 0.9.2. For development docs, go here.
Pulsar ships with its own HTTP parser used by both server and the HTTP client. Headers are collected using the Headers data structure which exposes a list/dictionary-type interface.
Handle basic and digest authentication on the server.
Parse an HTTP basic/digest authorisation header.
Parameters: | value – the authorisation header to parse. |
---|---|
Returns: | either None if the header was invalid or
not given, otherwise an Auth object. |
pulsar.apps.wsgi.structures.
Accept
[source]¶An Accept
object is a tuple subclass for tuples of
(value, quality)
tuples. It is automatically sorted by quality.
All Accept
objects work similar to a list but provide extra
functionality for working with the data. Containment checks are
normalised to the rules of that header:
>>> a = CharsetAccept([('ISO-8859-1', 1), ('utf-8', 0.7)])
>>> a.best
'ISO-8859-1'
>>> 'iso-8859-1' in a
True
>>> 'UTF8' in a
True
>>> 'utf7' in a
False
To get the quality for an item you can use normal item lookup:
>>> print(a['utf-8'])
0.7
>>> a(['utf7'])
0
best
¶The best match as value.
best_match
(matches, default=None)[source]¶Returns the best match from a list of possible matches based on the quality of the client. If two items have the same quality, the one is returned that comes first.
Parameters: |
|
---|
find
(key)[source]¶Get the position of an entry or return -1.
Parameters: | key – The key to be looked up. |
---|
index
(key)[source]¶Get the position of an entry or raise ValueError
.
Parameters: | key – The key to be looked up. |
---|
Changed in version 0.5: This used to raise IndexError
, which was inconsistent
with the list API.
pulsar.apps.wsgi.structures.
CharsetAccept
[source]¶Like Accept
but with normalisation for charsets.
The pulsar.apps.wsgi.utils
module include several utilities used
by various components in the wsgi application