本文整理汇总了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)