當前位置: 首頁>>代碼示例>>Python>>正文


Python httputil.HTTPOutputError方法代碼示例

本文整理匯總了Python中tornado.httputil.HTTPOutputError方法的典型用法代碼示例。如果您正苦於以下問題:Python httputil.HTTPOutputError方法的具體用法?Python httputil.HTTPOutputError怎麽用?Python httputil.HTTPOutputError使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在tornado.httputil的用法示例。


在下文中一共展示了httputil.HTTPOutputError方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: finish

# 需要導入模塊: from tornado import httputil [as 別名]
# 或者: from tornado.httputil import HTTPOutputError [as 別名]
def finish(self):
        if (self._expected_content_remaining is not None and
                self._expected_content_remaining != 0):
            self._error = httputil.HTTPOutputError(
                "Tried to write %d bytes less than Content-Length" %
                self._expected_content_remaining)
            raise self._error
        self._finished = True 
開發者ID:tao12345666333,項目名稱:tornado-zh,代碼行數:10,代碼來源:wsgi.py

示例2: write

# 需要導入模塊: from tornado import httputil [as 別名]
# 或者: from tornado.httputil import HTTPOutputError [as 別名]
def write(self, chunk, callback=None):
        if self._expected_content_remaining is not None:
            self._expected_content_remaining -= len(chunk)
            if self._expected_content_remaining < 0:
                self._error = httputil.HTTPOutputError(
                    "Tried to write more data than Content-Length")
                raise self._error
        self._write_buffer.append(chunk)
        if callback is not None:
            callback()
        return _dummy_future 
開發者ID:tao12345666333,項目名稱:tornado-zh,代碼行數:13,代碼來源:wsgi.py

示例3: _format_chunk

# 需要導入模塊: from tornado import httputil [as 別名]
# 或者: from tornado.httputil import HTTPOutputError [as 別名]
def _format_chunk(self, chunk):
        if self._expected_content_remaining is not None:
            self._expected_content_remaining -= len(chunk)
            if self._expected_content_remaining < 0:
                # Close the stream now to stop further framing errors.
                self.stream.close()
                raise httputil.HTTPOutputError(
                    "Tried to write more data than Content-Length")
        if self._chunking_output and chunk:
            # Don't write out empty chunks because that means END-OF-STREAM
            # with chunked encoding
            return utf8("%x" % len(chunk)) + b"\r\n" + chunk + b"\r\n"
        else:
            return chunk 
開發者ID:tao12345666333,項目名稱:tornado-zh,代碼行數:16,代碼來源:http1connection.py

示例4: finish

# 需要導入模塊: from tornado import httputil [as 別名]
# 或者: from tornado.httputil import HTTPOutputError [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: _format_chunk

# 需要導入模塊: from tornado import httputil [as 別名]
# 或者: from tornado.httputil import HTTPOutputError [as 別名]
def _format_chunk(self, chunk: bytes) -> bytes:
        if self._expected_content_remaining is not None:
            self._expected_content_remaining -= len(chunk)
            if self._expected_content_remaining < 0:
                # Close the stream now to stop further framing errors.
                self.stream.close()
                raise httputil.HTTPOutputError(
                    "Tried to write more data than Content-Length"
                )
        if self._chunking_output and chunk:
            # Don't write out empty chunks because that means END-OF-STREAM
            # with chunked encoding
            return utf8("%x" % len(chunk)) + b"\r\n" + chunk + b"\r\n"
        else:
            return chunk 
開發者ID:opendevops-cn,項目名稱:opendevops,代碼行數:17,代碼來源:http1connection.py

示例6: finish

# 需要導入模塊: from tornado import httputil [as 別名]
# 或者: from tornado.httputil import HTTPOutputError [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

示例7: write

# 需要導入模塊: from tornado import httputil [as 別名]
# 或者: from tornado.httputil import HTTPOutputError [as 別名]
def write(self, chunk, callback=None):
        if self._expected_content_remaining is not None:
            self._expected_content_remaining -= len(chunk)
            if self._expected_content_remaining < 0:
                self._error = httputil.HTTPOutputError(
                    "Tried to write more data than Content-Length")
                raise self._error
        self._write_buffer.append(chunk)
        if callback is not None:
            callback()
        return _dummy_future() 
開發者ID:tp4a,項目名稱:teleport,代碼行數:13,代碼來源:wsgi.py

示例8: finish

# 需要導入模塊: from tornado import httputil [as 別名]
# 或者: from tornado.httputil import HTTPOutputError [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

示例9: write

# 需要導入模塊: from tornado import httputil [as 別名]
# 或者: from tornado.httputil import HTTPOutputError [as 別名]
def write(self, chunk, callback=None):
        if chunk:
            if self._outgoing_content_remaining is not None:
                self._outgoing_content_remaining -= len(chunk)
                if self._outgoing_content_remaining < 0:
                    raise HTTPOutputError(
                        "Tried to write more data than Content-Length")
        return self._write_chunk(chunk, callback) 
開發者ID:bdarnell,項目名稱:tornado_http2,代碼行數:10,代碼來源:stream.py

示例10: finish

# 需要導入模塊: from tornado import httputil [as 別名]
# 或者: from tornado.httputil import HTTPOutputError [as 別名]
def finish(self):
        if (self._outgoing_content_remaining is not None and
                self._outgoing_content_remaining != 0):
            raise HTTPOutputError(
                "Tried to write %d bytes less than Content-Length" %
                self._outgoing_content_remaining)
        return self._write_end_stream() 
開發者ID:bdarnell,項目名稱:tornado_http2,代碼行數:9,代碼來源:stream.py


注:本文中的tornado.httputil.HTTPOutputError方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。