當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。