本文整理匯總了Python中gunicorn.util.write方法的典型用法代碼示例。如果您正苦於以下問題:Python util.write方法的具體用法?Python util.write怎麽用?Python util.write使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類gunicorn.util
的用法示例。
在下文中一共展示了util.write方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: write
# 需要導入模塊: from gunicorn import util [as 別名]
# 或者: from gunicorn.util import write [as 別名]
def write(self, arg):
self.send_headers()
if not isinstance(arg, binary_type):
raise TypeError('%r is not a byte' % arg)
arglen = len(arg)
tosend = arglen
if self.response_length is not None:
if self.sent >= self.response_length:
# Never write more than self.response_length bytes
return
tosend = min(self.response_length - self.sent, tosend)
if tosend < arglen:
arg = arg[:tosend]
# Sending an empty chunk signals the end of the
# response and prematurely closes the response
if self.chunked and tosend == 0:
return
self.sent += tosend
util.write(self.sock, arg, self.chunked)
示例2: send_headers
# 需要導入模塊: from gunicorn import util [as 別名]
# 或者: from gunicorn.util import write [as 別名]
def send_headers(self):
if self.headers_sent:
return
tosend = self.default_headers()
tosend.extend(["%s: %s\r\n" % (k, v) for k, v in self.headers])
header_str = "%s\r\n" % "".join(tosend)
util.write(self.sock, util.to_bytestring(header_str, "ascii"))
self.headers_sent = True
示例3: write_file
# 需要導入模塊: from gunicorn import util [as 別名]
# 或者: from gunicorn.util import write [as 別名]
def write_file(self, respiter):
if not self.sendfile(respiter):
for item in respiter:
self.write(item)