Open
Description
Is your feature request related to a problem? Please describe.
Currently, the requests
api of curl_cffi
is missing prepare_request
or httpx's build_request
method. The method is useful to construct request object and ability to view or edit the request object before sending the request via Session().send
or Client().send()
.
Describe the solution you'd like
httpx's build_request
or requests' prepare_request
method implemented in the requests api of curl_cffi
Describe alternatives you've considered
Using curl_cffi
as requests
adapter, so expected requests features are available.
Context
An example of the usefulness of build_request
method in action.
client = requests.Session()
# build_request is httpx method, similar to prepare_request
req = client.build_request(method: 'GET', url, headers, cookies, data)
# show request headers
req.headers
# Update user-agent header
req.headers['User-Agent'] = 'my_web_crawler/0.1'
# show request payload
req.content
# Update request payload using json string
data = { 'hello': 'world'}
req.content = bytes(json.dumps(data), 'utf-8')
# Update request method
req.method = 'POST'
# send the built request after fixing the issue
resp = client.send(req)