Giter Club home page Giter Club logo

Comments (20)

rogerleite avatar rogerleite commented on August 22, 2024

I don't think this is HTTPI's responsibility. To help with it, you can use block to access "native" client. In my tests, only with Curb client i could set follow location option. Httpclient does not have a "follow setter".

# using version 1.1.1
request = HTTPI::Request.new("http://google.com")
response = HTTPI.get(request, :curb)
puts response.code  # => 301

response = HTTPI.get(request, :curb) do |client|
  client.follow_location = true
end
puts response.code  # => 200
# using version 2.0.0.rc1
request = HTTPI::Request.new("http://google.com")
response = HTTPI.get(request, :curb)
puts response.code  # => 301

response = HTTPI.request(:get, request, :curb) do |client|
  client.follow_location = true
end
puts response.code  # => 200

I started a client that wraps HTTPI and have many features, one of them is follow redirect. You can try http_monkey or another client of course.

Hope that helps,

Roger Leite

from httpi.

rubiii avatar rubiii commented on August 22, 2024

i'm not sure about whether this should be supported or not. i'd like to be httpi as complete as possible, but since it's possible to manually follow redirects (or directly configure the client), this is not on top of my todo list right now.

if anyone has an opinion about this, let me know.

from httpi.

rogerleite avatar rogerleite commented on August 22, 2024

Study on HTTPI adapters about redirect feature:

  • curb supports by setting attribute on native client.
  • net/http does not support.
  • httpclient has the feature, but, we can't pass the option to native client, because is on the "request" moment.
  • em-http-request has the same problem like httpclient.

My opinion:
I don't think that HTTPI have to be this feature.
HTTPI have to support "send options" to native clients, if we want to do something about this.

from httpi.

rubiii avatar rubiii commented on August 22, 2024

savonrb/wasabi#18

from httpi.

rubiii avatar rubiii commented on August 22, 2024

thanks for doing the research @rogerleite. i appreciate it. since this is definitely a problem for savon,
i need to look into this some more.

from httpi.

rogerleite avatar rogerleite commented on August 22, 2024

@rubiii make wasabi responsible to follow redirect is an option. At Resolver you can check for responses [301, 302, 303, 307], change request.url and call load_from_remote again. I don't know if this have some side effect, but is an idea.

from httpi.

rubiii avatar rubiii commented on August 22, 2024

i actually started doing exactly that a few hours ago, before i came back to respond to this ticket. i think the http response definitely needs a #redirect? method along with #success? and i'm also not sure if redirects should be considered an error.

but implementing redirects in a wsdl parser library felt weird. don't know.

from httpi.

rogerleite avatar rogerleite commented on August 22, 2024

You're right.

Doesn't looks difficult to implement after adapter request. Put an #follow_redirect attribute on Request, with #redirect? on Response and it's easy to implement. My only fear is to bloat HTTPI.

from httpi.

rubiii avatar rubiii commented on August 22, 2024

it definitely comes with a cost to add any feature, but since httpi was build to support savon and it's actually causing problems, it just has to be fixed. thanks. i'll get back to this tomorrow.

from httpi.

rogerleite avatar rogerleite commented on August 22, 2024

👍

from httpi.

owain68 avatar owain68 commented on August 22, 2024

Has anyone come up with a solution to this?

from httpi.

rubiii avatar rubiii commented on August 22, 2024

don't think so. feel free to jump in.

from httpi.

tjarratt avatar tjarratt commented on August 22, 2024

@rogerleite I'm following up on this issue after seeing some activity on savonrb/wasabi#18 -- do you have any strong feelings on this?

I see some discussion of implementing this behavior in Wasabi versus implementing it in HTTPI. @rubiii's thoughts re: implementing it in the WSDL parser definitely makes me think twice, although I understand how complicated it is to implement it in HTTPI (because of the adapters... oh no the adapters).

Let's make a decision so we can close one of these two issues and try to make some forward progress. You've thought about this a lot, are you comfortable saying this is outside the scope of HTTPI and it should happen in Wasabi ?

from httpi.

rogerleite avatar rogerleite commented on August 22, 2024

Hi @tjarratt. Thinking more about this, i agree with @rubiii and we should implement this on HTTPI.
Here are some ideas to implement this on HTTPI:

  • We'll need a #follow_redirect attribute on Request object.
  • Capture response on request and follow redirect if response #redirect?.

I think this is the easiest way. What do you think @tjarratt?

from httpi.

tjarratt avatar tjarratt commented on August 22, 2024

👍

That sounds like the easiest way forward without bloating the interface too much.

from httpi.

mikeantonelli avatar mikeantonelli commented on August 22, 2024

Is anyone actively working on this?

from httpi.

rogerleite avatar rogerleite commented on August 22, 2024

@mikeantonelli maybe @tjarratt started something.

from httpi.

mikeantonelli avatar mikeantonelli commented on August 22, 2024

@rogerleite, I made a first pass at it: mikeantonelli/httpi:02c223d, and the integration: mikeantonelli/savon:3295603. Thoughts?

from httpi.

tjarratt avatar tjarratt commented on August 22, 2024

Looks good! Wouldn't hurt to add a simple integration test in Savon. It's been my experience that these integration points are the most likely to be broken during aggressive refactoring and merging pull requests.

from httpi.

mikeantonelli avatar mikeantonelli commented on August 22, 2024

@tjarratt, I opened #117 here and savonrb/savon#589, which would require minor update once #117 is merged and released.

from httpi.

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.