Open dululu opened 3 months ago
s = requests.Session()
s.get('https://httpbin.org/cookies/set/sessioncookie/123456789') r = s.get('https://httpbin.org/cookies')
print(r.text)
- Request and Response Objects[¶](https://requests.readthedocs.io/en/latest/user/advanced/#request-and-response-objects)
- Prepared Requests[¶](https://requests.readthedocs.io/en/latest/user/advanced/#prepared-requests)
预准备请求(Prepared Requests)是指在发送HTTP请求之前,将请求参数、头部信息、URL等预先设置好的请求对象。
- SSL Cert Verification[¶](https://requests.readthedocs.io/en/latest/user/advanced/#ssl-cert-verification)
SSL证书验证(`SSL Certificate Verification`)是在进行安全的`HTTP`S通信时,验证服务器端提供的SSL证书的有效性和可信任性的过程。当客户端与服务器建立HTTPS连接时,**服务器**会向**客户端**提供一个SSL证书,其中包含了**服务器的公钥和其他相关信息。客户端需要验证此证书,以确保与服务器建立的连接是安全的、可信的。**
>Requests can also ignore verifying the SSL certificate if you set verify to False:忽略SSL证书验证
By default, verify is set to True. Option verify only applies to host certs.
```python
requests.get('https://kennethreitz.org', verify=False)
<Response [200]>
HTTPS
)中,服务器可以要求客户端提供有效的客户端证书,以验证客户端的身份。客户端证书包含了客户端的公钥和其他相关信息,由可信任的证书颁发机构(Certificate Authority,CA
)签发。with open('massive-body', 'rb') as f:
requests.post('http://some.url/streamed', data=f)
Requests
SSL Cert Verification
Quickstart¶
r.headers['Content-Type'] 'application/json'
r.headers.get('content-type') 'application/json'