Search code examples
encodingurlencodehttpie

Is there a way to force httpie to use '%20' instead of '+' for spaces in query parameters?


Using httpie v2.3.0, I am interacting with a REST api that recognizes %20 but not + for space encodings in the values of query parameters. Is there a way to change httpie behavior to achieve the desired behavior below?

Query:

http -v :9000/query/bugsigdb/jaccard_nbor_ss 'source.type==signature' \
  source=='Signature 123' e_type==Signature_Taxonomy rev_e_type==Taxonomy_Signature

Results in:

GET /query/bugsigdb/jaccard_nbor_ss?source.type=signature&source=Signature+123&e_type=Signature_Taxonomy&rev_e_type=Taxonomy_Signature HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Host: localhost:9000
User-Agent: HTTPie/2.3.0

Desired result:

GET /query/bugsigdb/jaccard_nbor_ss?source.type=signature&source=Signature%20123&e_type=Signature_Taxonomy&rev_e_type=Taxonomy_Signature HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Host: localhost:9000
User-Agent: HTTPie/2.3.0

Note the difference between Signature+123 and Signature%20123.


Solution

  • Currently, it’s not possible to instruct HTTPie to use %20 instead of + for spaces when you use the param==value syntax. If you want to have control over this, then specifying the params as part of URL is the way to go. You can try opening a new issue for this: https://github.com/httpie/httpie/issues/new