question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

URL characters encoding

See original GitHub issue

Hi!

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:closed
  • Created 9 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
sigmavirus24commented, Jan 22, 2015

@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.

0reactions
rkiyanchukcommented, Jan 21, 2015

@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 like httpie does — without encoding [, and @ — so it just additionally supports our conclusion that httpie does the right thing and YiDB is processing the incoming requests wrong.

Read more comments on GitHub >

github_iconTop Results From Across the Web

HTML URL Encoding Reference - W3Schools
Character From Windows‑1252 From UTF‑8 space %20 %20 ! %21 %21 " %22 %22
Read more >
HTML - URL Encoding - Tutorialspoint
Decimal Hex Value Character URL Encode 128 80 € %80 129 81 %81 130 82 ‚ %82
Read more >
URL Encode and Decode - Online
Encode to URL-encoded format or decode from it with various advanced options. Our site has an easy to use online tool to convert...
Read more >
What is URL Encoding and How does it work? | URLEncoder
Decimal Character URL Encoding (UTF‑8) 0 NUL(null character) %00 1 SOH(start of header) %01 2 STX(start of text) %02
Read more >
HTML URL-encoding Reference - ESO.org
Hexadecimal values can be used to display non-standard letters and characters in browsers and plug-ins. URL-encoding from %00 to %8f. ASCII Value, URL-encode...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found