当前位置: 首页>>代码示例>>Python>>正文


Python httputil.HTTPConnection方法代码示例

本文整理汇总了Python中tornado.httputil.HTTPConnection方法的典型用法代码示例。如果您正苦于以下问题:Python httputil.HTTPConnection方法的具体用法?Python httputil.HTTPConnection怎么用?Python httputil.HTTPConnection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tornado.httputil的用法示例。


在下文中一共展示了httputil.HTTPConnection方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: write

# 需要导入模块: from tornado import httputil [as 别名]
# 或者: from tornado.httputil import HTTPConnection [as 别名]
def write(self, chunk, callback=None):
        """Implements `.HTTPConnection.write`.

        For backwards compatibility is is allowed but deprecated to
        skip `write_headers` and instead call `write()` with a
        pre-encoded header block.
        """
        future = None
        if self.stream.closed():
            future = self._write_future = Future()
            self._write_future.set_exception(iostream.StreamClosedError())
            self._write_future.exception()
        else:
            if callback is not None:
                self._write_callback = stack_context.wrap(callback)
            else:
                future = self._write_future = Future()
            self._pending_write = self.stream.write(self._format_chunk(chunk))
            self._pending_write.add_done_callback(self._on_write_complete)
        return future 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:22,代码来源:http1connection.py

示例2: write

# 需要导入模块: from tornado import httputil [as 别名]
# 或者: from tornado.httputil import HTTPConnection [as 别名]
def write(self, chunk: bytes) -> "Future[None]":
        """Implements `.HTTPConnection.write`.

        For backwards compatibility it is allowed but deprecated to
        skip `write_headers` and instead call `write()` with a
        pre-encoded header block.
        """
        future = None
        if self.stream.closed():
            future = self._write_future = Future()
            self._write_future.set_exception(iostream.StreamClosedError())
            self._write_future.exception()
        else:
            future = self._write_future = Future()
            self._pending_write = self.stream.write(self._format_chunk(chunk))
            future_add_done_callback(self._pending_write, self._on_write_complete)
        return future 
开发者ID:opendevops-cn,项目名称:opendevops,代码行数:19,代码来源:http1connection.py

示例3: write

# 需要导入模块: from tornado import httputil [as 别名]
# 或者: from tornado.httputil import HTTPConnection [as 别名]
def write(self, chunk, callback=None):
        """Implements `.HTTPConnection.write`.

        For backwards compatibility it is allowed but deprecated to
        skip `write_headers` and instead call `write()` with a
        pre-encoded header block.
        """
        future = None
        if self.stream.closed():
            future = self._write_future = Future()
            self._write_future.set_exception(iostream.StreamClosedError())
            self._write_future.exception()
        else:
            if callback is not None:
                warnings.warn("callback argument is deprecated, use returned Future instead",
                              DeprecationWarning)
                self._write_callback = stack_context.wrap(callback)
            else:
                future = self._write_future = Future()
            self._pending_write = self.stream.write(self._format_chunk(chunk))
            self._pending_write.add_done_callback(self._on_write_complete)
        return future 
开发者ID:tp4a,项目名称:teleport,代码行数:24,代码来源:http1connection.py

示例4: finish

# 需要导入模块: from tornado import httputil [as 别名]
# 或者: from tornado.httputil import HTTPConnection [as 别名]
def finish(self):
        """Implements `.HTTPConnection.finish`."""
        if (self._expected_content_remaining is not None and
                self._expected_content_remaining != 0 and
                not self.stream.closed()):
            self.stream.close()
            raise httputil.HTTPOutputError(
                "Tried to write %d bytes less than Content-Length" %
                self._expected_content_remaining)
        if self._chunking_output:
            if not self.stream.closed():
                self._pending_write = self.stream.write(b"0\r\n\r\n")
                self._pending_write.add_done_callback(self._on_write_complete)
        self._write_finished = True
        # If the app finished the request while we're still reading,
        # divert any remaining data away from the delegate and
        # close the connection when we're done sending our response.
        # Closing the connection is the only way to avoid reading the
        # whole input body.
        if not self._read_finished:
            self._disconnect_on_finish = True
        # No more data is coming, so instruct TCP to send any remaining
        # data immediately instead of waiting for a full packet or ack.
        self.stream.set_nodelay(True)
        if self._pending_write is None:
            self._finish_request(None)
        else:
            self._pending_write.add_done_callback(self._finish_request) 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:30,代码来源:http1connection.py

示例5: start_request

# 需要导入模块: from tornado import httputil [as 别名]
# 或者: from tornado.httputil import HTTPConnection [as 别名]
def start_request(
        self, server_conn: object, request_conn: httputil.HTTPConnection
    ) -> httputil.HTTPMessageDelegate:
        if isinstance(self.request_callback, httputil.HTTPServerConnectionDelegate):
            delegate = self.request_callback.start_request(server_conn, request_conn)
        else:
            delegate = _CallableAdapter(self.request_callback, request_conn)

        if self.xheaders:
            delegate = _ProxyAdapter(delegate, request_conn)

        return delegate 
开发者ID:opendevops-cn,项目名称:opendevops,代码行数:14,代码来源:httpserver.py

示例6: __init__

# 需要导入模块: from tornado import httputil [as 别名]
# 或者: from tornado.httputil import HTTPConnection [as 别名]
def __init__(
        self,
        request_callback: Callable[[httputil.HTTPServerRequest], None],
        request_conn: httputil.HTTPConnection,
    ) -> None:
        self.connection = request_conn
        self.request_callback = request_callback
        self.request = None  # type: Optional[httputil.HTTPServerRequest]
        self.delegate = None
        self._chunks = []  # type: List[bytes] 
开发者ID:opendevops-cn,项目名称:opendevops,代码行数:12,代码来源:httpserver.py

示例7: headers_received

# 需要导入模块: from tornado import httputil [as 别名]
# 或者: from tornado.httputil import HTTPConnection [as 别名]
def headers_received(
        self,
        start_line: Union[httputil.RequestStartLine, httputil.ResponseStartLine],
        headers: httputil.HTTPHeaders,
    ) -> Optional[Awaitable[None]]:
        # TODO: either make context an official part of the
        # HTTPConnection interface or figure out some other way to do this.
        self.connection.context._apply_xheaders(headers)  # type: ignore
        return self.delegate.headers_received(start_line, headers) 
开发者ID:opendevops-cn,项目名称:opendevops,代码行数:11,代码来源:httpserver.py

示例8: start_request

# 需要导入模块: from tornado import httputil [as 别名]
# 或者: from tornado.httputil import HTTPConnection [as 别名]
def start_request(
        self, server_conn: object, request_conn: httputil.HTTPConnection
    ) -> httputil.HTTPMessageDelegate:
        return _RoutingDelegate(self, server_conn, request_conn) 
开发者ID:opendevops-cn,项目名称:opendevops,代码行数:6,代码来源:routing.py

示例9: __init__

# 需要导入模块: from tornado import httputil [as 别名]
# 或者: from tornado.httputil import HTTPConnection [as 别名]
def __init__(self, connection: httputil.HTTPConnection) -> None:
        self.connection = connection 
开发者ID:opendevops-cn,项目名称:opendevops,代码行数:4,代码来源:routing.py

示例10: finish

# 需要导入模块: from tornado import httputil [as 别名]
# 或者: from tornado.httputil import HTTPConnection [as 别名]
def finish(self) -> None:
        """Implements `.HTTPConnection.finish`."""
        if (
            self._expected_content_remaining is not None
            and self._expected_content_remaining != 0
            and not self.stream.closed()
        ):
            self.stream.close()
            raise httputil.HTTPOutputError(
                "Tried to write %d bytes less than Content-Length"
                % self._expected_content_remaining
            )
        if self._chunking_output:
            if not self.stream.closed():
                self._pending_write = self.stream.write(b"0\r\n\r\n")
                self._pending_write.add_done_callback(self._on_write_complete)
        self._write_finished = True
        # If the app finished the request while we're still reading,
        # divert any remaining data away from the delegate and
        # close the connection when we're done sending our response.
        # Closing the connection is the only way to avoid reading the
        # whole input body.
        if not self._read_finished:
            self._disconnect_on_finish = True
        # No more data is coming, so instruct TCP to send any remaining
        # data immediately instead of waiting for a full packet or ack.
        self.stream.set_nodelay(True)
        if self._pending_write is None:
            self._finish_request(None)
        else:
            future_add_done_callback(self._pending_write, self._finish_request) 
开发者ID:opendevops-cn,项目名称:opendevops,代码行数:33,代码来源:http1connection.py

示例11: finish

# 需要导入模块: from tornado import httputil [as 别名]
# 或者: from tornado.httputil import HTTPConnection [as 别名]
def finish(self):
        """Implements `.HTTPConnection.finish`."""
        if (self._expected_content_remaining is not None and
                self._expected_content_remaining != 0 and
                not self.stream.closed()):
            self.stream.close()
            raise httputil.HTTPOutputError(
                "Tried to write %d bytes less than Content-Length" %
                self._expected_content_remaining)
        if self._chunking_output:
            if not self.stream.closed():
                self._pending_write = self.stream.write(b"0\r\n\r\n")
                self._pending_write.add_done_callback(self._on_write_complete)
        self._write_finished = True
        # If the app finished the request while we're still reading,
        # divert any remaining data away from the delegate and
        # close the connection when we're done sending our response.
        # Closing the connection is the only way to avoid reading the
        # whole input body.
        if not self._read_finished:
            self._disconnect_on_finish = True
        # No more data is coming, so instruct TCP to send any remaining
        # data immediately instead of waiting for a full packet or ack.
        self.stream.set_nodelay(True)
        if self._pending_write is None:
            self._finish_request(None)
        else:
            future_add_done_callback(self._pending_write, self._finish_request) 
开发者ID:tp4a,项目名称:teleport,代码行数:30,代码来源:http1connection.py

示例12: __init__

# 需要导入模块: from tornado import httputil [as 别名]
# 或者: from tornado.httputil import HTTPConnection [as 别名]
def __init__(
        self, router: Router, server_conn: object, request_conn: httputil.HTTPConnection
    ) -> None:
        self.server_conn = server_conn
        self.request_conn = request_conn
        self.delegate = None  # type: Optional[httputil.HTTPMessageDelegate]
        self.router = router  # type: Router 
开发者ID:tp4a,项目名称:teleport,代码行数:9,代码来源:routing.py


注:本文中的tornado.httputil.HTTPConnection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。