本文整理汇总了Python中brotli.error方法的典型用法代码示例。如果您正苦于以下问题:Python brotli.error方法的具体用法?Python brotli.error怎么用?Python brotli.error使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类brotli
的用法示例。
在下文中一共展示了brotli.error方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: send_request
# 需要导入模块: import brotli [as 别名]
# 或者: from brotli import error [as 别名]
def send_request(self, http_request):
"""
Send a request and get response
"""
self.request_object = http_request
self.build_socket()
self.build_request()
try:
self.sock.send(self.request)
except socket.error as err:
raise errors.TestError(
'We were unable to send the request to the socket',
{
'msg': err,
'function': 'http.HttpUA.send_request'
})
self.get_response()
示例2: decompress
# 需要导入模块: import brotli [as 别名]
# 或者: from brotli import error [as 别名]
def decompress(self, data):
if not data:
return data
if not self._first_try:
return self._obj.decompress(data)
self._data += data
try:
decompressed = self._obj.decompress(data)
if decompressed:
self._first_try = False
self._data = None
return decompressed
except zlib.error:
self._first_try = False
self._obj = zlib.decompressobj(-zlib.MAX_WBITS)
try:
return self.decompress(self._data)
finally:
self._data = None