本文整理匯總了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