Comments (20)
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.
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.
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.
from httpi.
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.
@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.
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.
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.
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.
👍
from httpi.
Has anyone come up with a solution to this?
from httpi.
don't think so. feel free to jump in.
from httpi.
@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.
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 onRequest
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.
👍
That sounds like the easiest way forward without bloating the interface too much.
from httpi.
Is anyone actively working on this?
from httpi.
@mikeantonelli maybe @tjarratt started something.
from httpi.
@rogerleite, I made a first pass at it: mikeantonelli/httpi:02c223d, and the integration: mikeantonelli/savon:3295603. Thoughts?
from httpi.
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.
@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)
- HTTPI (at least with default adapter) doesn't automatically send basic auth headers HOT 3
- Deprecation warning in ruby 2.5 HOT 4
- Connection reset by peer using HTTPI but working on open-uri HOT 2
- Read Timeout and Open Timeout is not working (under savon) HOT 3
- Diese Präsenz ist derzeit nicht verfügbar. HOT 1
- TLSv1_3 parameter support for ssl_version HOT 1
- Enforce IPv6 use? HOT 2
- Allow common `block` for all requests HOT 4
- Licence issue with Socksify gem HOT 4
- How can we define the environment for mounted rails apps HOT 3
- Savon breaks with http gem >= 5.0.0 HOT 2
- chore: Fix rspec deprecation warnings
- CI stopped on Travis HOT 1
- Can we remove socksify as a dependency? HOT 3
- Optional dependency rack used internally HOT 3
- HTTPi fails with https endpoint HOT 2
- rack 3.0 support HOT 1
- The future of httpi HOT 4
- Rack::Utils::HeaderHash --> Rack::Headers HOT 2
- Warning on Ruby 3.3 HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from httpi.