8000 Cannot get .WithPath to handle URL-encoded value · Issue #448 · gavv/httpexpect · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Cannot get .WithPath to handle URL-encoded value #448

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
oloffl opened this issue Aug 29, 2024 · 1 comment
Open

Cannot get .WithPath to handle URL-encoded value #448

oloffl opened this issue Aug 29, 2024 · 1 comment
Labels
can't reproduce Unable to reproduce problem

Comments

@oloffl
Copy link
oloffl commented Aug 29, 2024

I am using httpexpect version 2.16.0 to test one of our endpoints that wants a url-encoded path.

It looks something like this

path := "some:data/thats/encoded@0.1.0
urlEncoded := url.QueryEscape(path)

e.GET("/data/{urlEncoded}").
  WithPath("urlEncoded", urlEncoded).
  Expect().
  Status(http.StatusOK)

httpexpect fails with the following output

GET /data/some%!A(MISSING)data%!F(MISSING)thats%!F(MISSING)encoded%!.(MISSING)0 HTTP/1.1

Any ideas on what I am doing wrong?

@gavv
Copy link
Owner
gavv commented Mar 3, 2025

Hi, thanks for report. I can't reproduce it neither in 2.16.0 nor in master.

I've added a couple of tests for this case, all are passing: 97e9161

For me, when I pass url-encoded argument to WithPath, it is added to request path as-is, and then http.Client url-encodes the whole path when sending request. So that piece of the path is actually url-encoded twice when it comes to server. Server url-decodes it, and server handler sees original url-encoded argument.

The error you quoted seems like printf-like formatting was used, but TBH I have no idea when it can be used for URL paths.

Can you provide a minimal reproducible example? Ideally based on master branch.

@gavv gavv added the can't reproduce Unable to reproduce problem label Mar 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
can't reproduce Unable to reproduce problem
Projects
None yet
Development

No branches or pull requests

2 participants
0