Public Member Functions | |
def | __contains__ |
def | __delitem__ |
def | __getitem__ |
def | __init__ |
def | __setitem__ |
def | add |
def | copy |
def | get |
def | get_all |
def | get_list |
def | parse |
def | parse_line |
def | update |
Private Attributes | |
_as_list | |
_last_key |
A dictionary that maintains ``Http-Header-Case`` for all keys. Supports multiple values per key via a pair of new methods, `add()` and `get_list()`. The regular dictionary interface returns a single value per key, with multiple values joined by a comma. >>> h = HTTPHeaders({"content-type": "text/html"}) >>> list(h.keys()) ['Content-Type'] >>> h["Content-Type"] 'text/html' >>> h.add("Set-Cookie", "A=B") >>> h.add("Set-Cookie", "C=D") >>> h["set-cookie"] 'A=B,C=D' >>> h.get_list("set-cookie") ['A=B', 'C=D'] >>> for (k,v) in sorted(h.get_all()): ... print('%s: %s' % (k,v)) ... Content-Type: text/html Set-Cookie: A=B Set-Cookie: C=D
Definition at line 96 of file httputil.py.
def tornado.httputil.HTTPHeaders.__init__ | ( | self, | |
args, | |||
kwargs | |||
) |
Definition at line 124 of file httputil.py.
def tornado.httputil.HTTPHeaders.__contains__ | ( | self, | |
name | |||
) |
Definition at line 216 of file httputil.py.
def tornado.httputil.HTTPHeaders.__delitem__ | ( | self, | |
name | |||
) |
Definition at line 211 of file httputil.py.
def tornado.httputil.HTTPHeaders.__getitem__ | ( | self, | |
name | |||
) |
Definition at line 208 of file httputil.py.
def tornado.httputil.HTTPHeaders.__setitem__ | ( | self, | |
name, | |||
value | |||
) |
Definition at line 203 of file httputil.py.
def tornado.httputil.HTTPHeaders.add | ( | self, | |
name, | |||
value | |||
) |
Adds a new value for the given key.
Definition at line 141 of file httputil.py.
def tornado.httputil.HTTPHeaders.copy | ( | self | ) |
Definition at line 228 of file httputil.py.
def tornado.httputil.HTTPHeaders.get | ( | self, | |
name, | |||
default = None |
|||
) |
Definition at line 220 of file httputil.py.
def tornado.httputil.HTTPHeaders.get_all | ( | self | ) |
Returns an iterable of all (name, value) pairs. If a header has multiple values, multiple pairs will be returned with the same name.
Definition at line 159 of file httputil.py.
def tornado.httputil.HTTPHeaders.get_list | ( | self, | |
name | |||
) |
Returns all values for the given header as a list.
Definition at line 154 of file httputil.py.
def tornado.httputil.HTTPHeaders.parse | ( | cls, | |
headers | |||
) |
Returns a dictionary from HTTP header text. >>> h = HTTPHeaders.parse("Content-Type: text/html\\r\\nContent-Length: 42\\r\\n") >>> sorted(h.items()) [('Content-Length', '42'), ('Content-Type', 'text/html')]
Definition at line 188 of file httputil.py.
def tornado.httputil.HTTPHeaders.parse_line | ( | self, | |
line | |||
) |
Updates the dictionary with a single header line. >>> h = HTTPHeaders() >>> h.parse_line("Content-Type: text/html") >>> h.get('content-type') 'text/html'
Definition at line 169 of file httputil.py.
def tornado.httputil.HTTPHeaders.update | ( | self, | |
args, | |||
kwargs | |||
) |
Definition at line 223 of file httputil.py.
tornado::httputil.HTTPHeaders::_as_list [private] |
Definition at line 124 of file httputil.py.
tornado::httputil.HTTPHeaders::_last_key [private] |
Definition at line 124 of file httputil.py.