本文整理匯總了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))