juancarlospaco / faster-than-requests

Faster requests on Python 3
https://gist.github.com/juancarlospaco/37da34ed13a609663f55f4466c4dbc3e
MIT License
1.1k stars 89 forks source link

seting header dont work #128

Closed just-taki closed 3 years ago

just-taki commented 3 years ago

Before you open a new bug

just-taki commented 3 years ago

when i set header faster_than_requests.set_headers([("Content-Type", "application/x-www-form-urlencoded"),("das","dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd")])

then send a post request ['{\n "args": {}, \n "data": "{query:van+helsing'}", \n "files": {}, \n "form": {}, \n "headers": {\n "Content-Length": "20", \n "Dnt": "1", \n "Host": "httpbin.org", \n "User-Agent": "Nim httpclient/1.4.2", \n "X-Amzn-Trace-Id": "Root=1-6013fe0a-64dc1f2d359939200570c2cc"\n }, \n "json": null, \n "origin": "", \n "url": "https://httpbin.org/post"\n}\n', 'application/json', '200 OK', '1.1', 'https://httpbin.org/post', '372', '{"server": @["gunicorn/19.9.0"], "content-length": @["372"], "access-control-allow-credentials": @["true"], "content-type": @["application/json"], "date": @["Fri, 29 Jan 2021 12:22:34 GMT"], "access-control-allow-origin": @["*"], "connection": @["keep-alive"]}']

the header are not setted how to fix

juancarlospaco commented 3 years ago

set_header() is for the functions that do not have a http_headers argument, you can pass the headers as an argument of the functions, like http_headers = [("key", "value")], this is mentioned on the documentation.

from faster_than_requests import post
print(
  post(url = "http://httpbin.org/post", http_headers = [("key", "value")] )
)