GithubHelp home page GithubHelp logo

URI encoding causing an issue about fakeweb HOT 2 OPEN

chrisk avatar chrisk commented on June 9, 2024
URI encoding causing an issue

from fakeweb.

Comments (2)

jonleighton avatar jonleighton commented on June 9, 2024 1

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

from fakeweb.

chrisk avatar chrisk commented on June 9, 2024

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?

from fakeweb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.