本文整理汇总了Python中tornado.httputil.parse_response_start_line方法的典型用法代码示例。如果您正苦于以下问题:Python httputil.parse_response_start_line方法的具体用法?Python httputil.parse_response_start_line怎么用?Python httputil.parse_response_start_line使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tornado.httputil
的用法示例。
在下文中一共展示了httputil.parse_response_start_line方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _curl_header_callback
# 需要导入模块: from tornado import httputil [as 别名]
# 或者: from tornado.httputil import parse_response_start_line [as 别名]
def _curl_header_callback(self, headers, header_callback, header_line):
header_line = native_str(header_line)
if header_callback is not None:
self.io_loop.add_callback(header_callback, header_line)
# header_line as returned by curl includes the end-of-line characters.
# whitespace at the start should be preserved to allow multi-line headers
header_line = header_line.rstrip()
if header_line.startswith("HTTP/"):
headers.clear()
try:
(__, __, reason) = httputil.parse_response_start_line(header_line)
header_line = "X-Http-Reason: %s" % reason
except httputil.HTTPInputError:
return
if not header_line:
return
headers.parse_line(header_line)
示例2: _curl_header_callback
# 需要导入模块: from tornado import httputil [as 别名]
# 或者: from tornado.httputil import parse_response_start_line [as 别名]
def _curl_header_callback(
self,
headers: httputil.HTTPHeaders,
header_callback: Callable[[str], None],
header_line_bytes: bytes,
) -> None:
header_line = native_str(header_line_bytes.decode("latin1"))
if header_callback is not None:
self.io_loop.add_callback(header_callback, header_line)
# header_line as returned by curl includes the end-of-line characters.
# whitespace at the start should be preserved to allow multi-line headers
header_line = header_line.rstrip()
if header_line.startswith("HTTP/"):
headers.clear()
try:
(__, __, reason) = httputil.parse_response_start_line(header_line)
header_line = "X-Http-Reason: %s" % reason
except httputil.HTTPInputError:
return
if not header_line:
return
headers.parse_line(header_line)
示例3: _curl_header_callback
# 需要导入模块: from tornado import httputil [as 别名]
# 或者: from tornado.httputil import parse_response_start_line [as 别名]
def _curl_header_callback(self, headers, header_callback, header_line):
header_line = native_str(header_line.decode('latin1'))
if header_callback is not None:
self.io_loop.add_callback(header_callback, header_line)
# header_line as returned by curl includes the end-of-line characters.
# whitespace at the start should be preserved to allow multi-line headers
header_line = header_line.rstrip()
if header_line.startswith("HTTP/"):
headers.clear()
try:
(__, __, reason) = httputil.parse_response_start_line(header_line)
header_line = "X-Http-Reason: %s" % reason
except httputil.HTTPInputError:
return
if not header_line:
return
headers.parse_line(header_line)
示例4: header_callback
# 需要导入模块: from tornado import httputil [as 别名]
# 或者: from tornado.httputil import parse_response_start_line [as 别名]
def header_callback(self, headers):
# The header callback will be called multiple times, once for the initial
# HTTP status line and once for each received header.
header_lines = headers
if self._response_status is None:
status_line, _, header_lines = headers.partition('\r\n')
self._response_status = httputil.parse_response_start_line(status_line)
self._response_headers.update(httputil.HTTPHeaders.parse(header_lines))