URL characters encoding
See original GitHub issueHi!
I am using awesome httpie
to talk to the REST API of YiDB tool which has unusual request URLs for querying that contain [
, @
and ]
. Examples follow:
GET repositories/cmsdb/branches/main/query/ApplicationService[@label="srp-app"]
GET repositories/cmsdb/branches/main/query/ServiceInstance[@domain =~ "ebay.*" and @activeManifestDiff = false]
The problem is:
when I use http
to query one of such URLs, I get 500
server error in response because these symbols ([
, @
, ]
) are passed to the server unencoded. The request URL to server ends up being:
http://localhost:8080/cms/repositories/Asset/branches/main/query/Server[@name="test"]
Dirty solution:
when I brutally use urllib
to encode that part of the URL string inside httpie
, it works great with the request URL ending up to be:
http://localhost:8080/cms/repositories/Asset/branches/main/query/Server%5B%40name%3D%22test%22%5D
Question is: What would be your recommendation to overcome this issue?
I have big doubts that this is necessary http
’s problem, but I would like to sort this out and be able to use the API with stock httpie
. So is there any way I can form the desired URL with CLI arguments, or is it undoable without code patching?
If it’s only through code change, I can prettify my changes and make a pull request to further discuss.
What are your thoughts on this?
Thank you!
Issue Analytics
- State:
- Created 9 years ago
- Comments:6
Top GitHub Comments
@zoresvit to be clear (and hopefully not condescending) I speak only for the library on top of which @jakubroztocil built httpie. If the project/@jakubroztocil wants to add
-G
and-d
that is their decision (as I said earlier). Regardless, they should not expect requests to provide any options, keyword arguments, or anything else to do this for them. This functionality would have to entirely live within httpie.@sigmavirus24 Just a follow-up regarding
curl
: it has some of its own URL globbing parser which can be turned off with-g
parameter. So when used with-g
it successfully forms the request URL just likehttpie
does — without encoding[
, and@
— so it just additionally supports our conclusion thathttpie
does the right thing andYiDB
is processing the incoming requests wrong.