Classes | |
class | _NormalizedHeaderCache |
class | HTTPConnection |
class | HTTPFile |
class | HTTPHeaders |
class | HTTPInputError |
class | HTTPMessageDelegate |
class | HTTPOutputError |
class | HTTPServerConnectionDelegate |
class | HTTPServerRequest |
class | SSLError |
Functions | |
def | _get_content_range |
def | _int_or_none |
def | _parse_header |
def | _parse_request_range |
def | _parseparam |
def | doctests |
def | format_timestamp |
def | parse_body_arguments |
def | parse_multipart_form_data |
def | parse_request_start_line |
def | parse_response_start_line |
def | url_concat |
Variables | |
tuple | _normalized_headers = _NormalizedHeaderCache(1000) |
tuple | RequestStartLine |
tuple | ResponseStartLine |
def tornado.httputil._get_content_range | ( | start, | |
end, | |||
total | |||
) | [private] |
Returns a suitable Content-Range header: >>> print(_get_content_range(None, 1, 4)) bytes 0-0/4 >>> print(_get_content_range(1, 3, 4)) bytes 1-2/4 >>> print(_get_content_range(None, None, 4)) bytes 0-3/4
Definition at line 640 of file httputil.py.
def tornado.httputil._int_or_none | ( | val | ) | [private] |
Definition at line 655 of file httputil.py.
def tornado.httputil._parse_header | ( | line | ) | [private] |
Parse a Content-type like header. Return the main content-type and a dictionary of options.
Definition at line 821 of file httputil.py.
def tornado.httputil._parse_request_range | ( | range_header | ) | [private] |
Parses a Range header. Returns either ``None`` or tuple ``(start, end)``. Note that while the HTTP headers use inclusive byte positions, this method returns indexes suitable for use in slices. >>> start, end = _parse_request_range("bytes=1-2") >>> start, end (1, 3) >>> [0, 1, 2, 3, 4][start:end] [1, 2] >>> _parse_request_range("bytes=6-") (6, None) >>> _parse_request_range("bytes=-6") (-6, None) >>> _parse_request_range("bytes=-0") (None, 0) >>> _parse_request_range("bytes=") (None, None) >>> _parse_request_range("foo=42") >>> _parse_request_range("bytes=1-2,6-10") Note: only supports one range (ex, ``bytes=1-2,6-10`` is not allowed). See [0] for the details of the range header. [0]: http://greenbytes.de/tech/webdav/draft-ietf-httpbis-p5-range-latest.html#byte.ranges
Definition at line 591 of file httputil.py.
def tornado.httputil._parseparam | ( | s | ) | [private] |
Definition at line 808 of file httputil.py.
def tornado.httputil.doctests | ( | ) |
Definition at line 842 of file httputil.py.
def tornado.httputil.format_timestamp | ( | ts | ) |
Formats a timestamp in the format used by HTTP. The argument may be a numeric timestamp as returned by `time.time`, a time tuple as returned by `time.gmtime`, or a `datetime.datetime` object. >>> format_timestamp(1359312200) 'Sun, 27 Jan 2013 18:43:20 GMT'
Definition at line 741 of file httputil.py.
def tornado.httputil.parse_body_arguments | ( | content_type, | |
body, | |||
arguments, | |||
files, | |||
headers = None |
|||
) |
Parses a form request body. Supports ``application/x-www-form-urlencoded`` and ``multipart/form-data``. The ``content_type`` parameter should be a string and ``body`` should be a byte string. The ``arguments`` and ``files`` parameters are dictionaries that will be updated with the parsed contents.
Definition at line 662 of file httputil.py.
def tornado.httputil.parse_multipart_form_data | ( | boundary, | |
data, | |||
arguments, | |||
files | |||
) |
Parses a ``multipart/form-data`` body. The ``boundary`` and ``data`` parameters are both byte strings. The dictionaries given in the arguments and files parameters will be updated with the contents of the body.
Definition at line 695 of file httputil.py.
def tornado.httputil.parse_request_start_line | ( | line | ) |
Returns a (method, path, version) tuple for an HTTP 1.x request line. The response is a `collections.namedtuple`. >>> parse_request_start_line("GET /foo HTTP/1.1") RequestStartLine(method='GET', path='/foo', version='HTTP/1.1')
Definition at line 766 of file httputil.py.
def tornado.httputil.parse_response_start_line | ( | line | ) |
Returns a (version, code, reason) tuple for an HTTP 1.x response line. The response is a `collections.namedtuple`. >>> parse_response_start_line("HTTP/1.1 200 OK") ResponseStartLine(version='HTTP/1.1', code=200, reason='OK')
Definition at line 788 of file httputil.py.
def tornado.httputil.url_concat | ( | url, | |
args | |||
) |
Concatenate url and argument dictionary regardless of whether url has existing query parameters. >>> url_concat("http://example.com/foo?a=b", dict(c="d")) 'http://example.com/foo?a=b&c=d'
Definition at line 564 of file httputil.py.
tuple tornado::httputil::_normalized_headers = _NormalizedHeaderCache(1000) |
Definition at line 93 of file httputil.py.
00001 collections.namedtuple( 00002 'RequestStartLine', ['method', 'path', 'version'])
Definition at line 762 of file httputil.py.
00001 collections.namedtuple( 00002 'ResponseStartLine', ['version', 'code', 'reason'])
Definition at line 784 of file httputil.py.