I need to send a request with query string containing square brackets: [, And it should not be encoded as %5b.
As the answer in this question <How to prevent python requests from percent encoding my URLs?> says,
I have tried putting the query string in the URL instead of passing params argument to get(), but requests still decides to encode the [ character anyway.
Wireshark:
- Sent with python
requests:
url = "http://localhost:2017/api/httpLatency?whiches=[%7B%22id%22:26,%22_type%22:%22subscriptionServer%22,%22sub%22:1%7D]"
r = requests.get(url)
- Another packet containing an unencoded
[in URL:
I also tried the solution in this GitHub issue of request, which is to prepare the Request object and send it yourself. It doesn't work either.
After doing some testing, I found out that some characters, like ( , : +, won't be URL-encoded if passed directly as part of URL, but characters like { [ will be URL-encoded anyway no matter passed as URL or as params arguments.
I wonder if this is a deliberate design of requests? If it is, why should requests force characters like [ { to be encoded, is it due to the safety issue?
And if it is not, is there a workaround for this problem? After hours of searching, I still couldn't find a way to make a request with an un-encoded [ character in the URL. Using urllib would be way too complex for me.
Any help would be appreciated!

