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

URI encoding causing an issue #16

Open
jonleighton opened this issue Jul 28, 2010 · 2 comments
Open

URI encoding causing an issue #16

jonleighton opened this issue Jul 28, 2010 · 2 comments

Comments

@jonleighton
Copy link

Hiya,

I have a URI like this:

http:://test.host/resource?date=2010-07-28T14:19:47Z

When Net::HTTP sends the request, it has turned it into:

http:://test.host/resource?date=2010-07-28T14%3A19%3A47Z

Which then doesn't get matched by FakeWeb.

If I put the parameter through CGI.escape then that solves the problem for me, but it'd be nice if FakeWeb worked that out itself.

Cheers

@chrisk
Copy link
Owner

chrisk commented Aug 16, 2010

I'm having trouble reproducing this. Net::HTTP seems to send out that request as-is, with no escaping of the query string. Here's my test (which passes):

def test_query_param_encoding
  FakeWeb.register_uri(:get, "http://example.com/?date=2010-07-28T14:19:47Z", :body => "body")
  response = Net::HTTP.start("example.com") { |query| query.get("/?date=2010-07-28T14:19:47Z") }
  assert_equal "body", response.body
end

Are you sure it's Net::HTTP that's doing the encoding?

@jonleighton
Copy link
Author

Hiya,

Thanks for your response. I agree with you that the above test works fine. In my real-world app I am actually using rest-client (http://github.com/archiloque/rest-client) to send requests, so I can only assume that rest-client is itself changing the URI before sending it to Net::HTTP.

However, it would be quite nice if Fakeweb could recognise CGI encoding in URIs and treat in indifferently. In other words, it would be nice if the following modified test passed (which would have solved my problem):

def test_query_param_encoding
  FakeWeb.register_uri(:get, "http://example.com/?date=2010-07-28T14:19:47Z", :body => "body")
  response = Net::HTTP.start("example.com") { |query| query.get("/?date=2010-07-28T14%3A19%3A47Z") }
  assert_equal "body", response.body
end

(And vice versa I guess, though that is less important as you are unlikely to specify a CGI encoded URL when writing your test.)

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