Public Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes
tornado.httputil.HTTPHeaders Class Reference

List of all members.

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

Static Private Member Functions

def _normalize_name

Private Attributes

 _as_list
 _last_key

Static Private Attributes

tuple _NORMALIZED_HEADER_RE = re.compile(r'^[A-Z0-9][a-z0-9]*(-[A-Z0-9][a-z0-9]*)*$')
dictionary _normalized_headers = {}

Detailed Description

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"})
>>> 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 28 of file httputil.py.


Constructor & Destructor Documentation

def tornado.httputil.HTTPHeaders.__init__ (   self,
  args,
  kwargs 
)

Definition at line 55 of file httputil.py.


Member Function Documentation

def tornado.httputil.HTTPHeaders.__contains__ (   self,
  name 
)

Definition at line 145 of file httputil.py.

def tornado.httputil.HTTPHeaders.__delitem__ (   self,
  name 
)

Definition at line 140 of file httputil.py.

def tornado.httputil.HTTPHeaders.__getitem__ (   self,
  name 
)

Definition at line 137 of file httputil.py.

def tornado.httputil.HTTPHeaders.__setitem__ (   self,
  name,
  value 
)

Definition at line 132 of file httputil.py.

def tornado.httputil.HTTPHeaders._normalize_name (   name) [static, private]
Converts a name to Http-Header-Case.

>>> HTTPHeaders._normalize_name("coNtent-TYPE")
'Content-Type'

Definition at line 165 of file httputil.py.

def tornado.httputil.HTTPHeaders.add (   self,
  name,
  value 
)
Adds a new value for the given key.

Definition at line 72 of file httputil.py.

Definition at line 157 of file httputil.py.

def tornado.httputil.HTTPHeaders.get (   self,
  name,
  default = None 
)

Definition at line 149 of file httputil.py.

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 88 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 83 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.iteritems())
[('Content-Length', '42'), ('Content-Type', 'text/html')]

Definition at line 117 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 98 of file httputil.py.

def tornado.httputil.HTTPHeaders.update (   self,
  args,
  kwargs 
)

Definition at line 152 of file httputil.py.


Member Data Documentation

Definition at line 55 of file httputil.py.

Definition at line 55 of file httputil.py.

tuple tornado::httputil.HTTPHeaders::_NORMALIZED_HEADER_RE = re.compile(r'^[A-Z0-9][a-z0-9]*(-[A-Z0-9][a-z0-9]*)*$') [static, private]

Definition at line 161 of file httputil.py.

dictionary tornado::httputil.HTTPHeaders::_normalized_headers = {} [static, private]

Definition at line 162 of file httputil.py.


The documentation for this class was generated from the following file:


rosbridge_server
Author(s): Jonathan Mace
autogenerated on Mon Oct 6 2014 06:58:14