本文整理匯總了Python中requests.models.PreparedRequest.headers方法的典型用法代碼示例。如果您正苦於以下問題:Python PreparedRequest.headers方法的具體用法?Python PreparedRequest.headers怎麽用?Python PreparedRequest.headers使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類requests.models.PreparedRequest
的用法示例。
在下文中一共展示了PreparedRequest.headers方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: deserialize_prepared_request
# 需要導入模塊: from requests.models import PreparedRequest [as 別名]
# 或者: from requests.models.PreparedRequest import headers [as 別名]
def deserialize_prepared_request(serialized):
p = PreparedRequest()
p.body = serialized['body']
p.headers = CaseInsensitiveDict(serialized['headers'])
p.method = serialized['method']
p.url = serialized['uri']
return p
示例2: copy_request
# 需要導入模塊: from requests.models import PreparedRequest [as 別名]
# 或者: from requests.models.PreparedRequest import headers [as 別名]
def copy_request(request):
"""Copy a Requests PreparedRequest."""
new_request = PreparedRequest()
new_request.method = request.method
new_request.url = request.url
new_request.body = request.body
new_request.hooks = request.hooks
new_request.headers = request.headers.copy()
return new_request
示例3: deserialize_prepared_request
# 需要導入模塊: from requests.models import PreparedRequest [as 別名]
# 或者: from requests.models.PreparedRequest import headers [as 別名]
def deserialize_prepared_request(serialized):
p = PreparedRequest()
p._cookies = RequestsCookieJar()
body = serialized['body']
if isinstance(body, dict):
original_body = body.get('string')
p.body = original_body or base64.b64decode(
body.get('base64_string', '').encode())
else:
p.body = body
h = [(k, from_list(v)) for k, v in serialized['headers'].items()]
p.headers = CaseInsensitiveDict(h)
p.method = serialized['method']
p.url = serialized['uri']
return p