I'm trying to make a POST request to my API using a fairly long (1017 characters) bearer token for authorization.
No matter what I try, when I initiate the request I get an error message stating that \u2026
(horizontal ellipsis) in position 512 cannot be encoded using "latin-1" encoding. Since I can't find any problem with the header I specified (or the ellipsis), my only explanation is that the requests module is silently truncating my token internally. Is that so? Can it be disabled? Are there any other solutions?
No, it does not truncate the header. You can see this by running the localhost http server which prints all requests received. Here's an example using 2000 character tags.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
|
Run it on localhost and then use requests to post the request:
1 2 3 4 5 6 |
|
Produces the following output:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
|
The above is the detailed content of Does the requests module truncate headers?. For more information, please follow other related articles on the PHP Chinese website!