Skip to content
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

Does not support URL-encoded content in URIs #116

Closed
jGleitz opened this issue Sep 11, 2023 · 2 comments
Closed

Does not support URL-encoded content in URIs #116

jGleitz opened this issue Sep 11, 2023 · 2 comments
Milestone

Comments

@jGleitz
Copy link

jGleitz commented Sep 11, 2023

I’m calling an API that uses a URL-encoded path variable (the AWS IoT HTTPS API). So my request looks like this:

POST /topics/$aws%2Fthings%2Ftest-host%2Fshadow%2Fname%2Ftest-shadow%2Fupdate

However, I can only match this request using

_mockHttp.Expect(Post, "/topics/$aws/things/test-host/shadow/name/patch_management/update")

This is the wrong expectation, as I also want to test that my code correctly encodes the path variable.

The underlying issue is that UrlEncoder uses URI.LocalPath, which decodes and URL-encoding (as all URI accessors do).

@richardszalay
Copy link
Owner

Hi @jGleitz, let me take a look at this. I remember that Android had some issues that required the use of LocalPath so I'll need to be careful with a fix here.

@richardszalay
Copy link
Owner

richardszalay commented Oct 3, 2023

It turns out I was wrong about the Android issue as it had nothing to do with LocalPath. I'm going to include a fix for this in the next version (7.0.0.0), but in the meantime you can use this as a workaround:

_mockHttp.Expect("*")
  .With(req => req.RequestUri.AbsolutePath == "/topics/$aws%2Fthings%2Ftest-host%2Fshadow%2Fname%2Ftest-shadow%2Fupdate")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants