Comments (3)
@adrianodennanni Thanks for opening this issue, this is a good conversation to have.
The exception class Mechanize::ResponseCodeError
is intended to wrap up a successful response from the server that has an HTTP status code other than 200, 301, or 302.
In the case you're describing, are you saying that you received a response from the server that was a 50x status code? Or was this a networking error? I'm a little confused by the string "(500, 501, 502, 503)" in the description.
from mechanize.
I will paste here an example of this happening.
The exception message for the Net::HTTPFatalError
was 503 "Service Unavailable"
.
A simple get, such as agent.get 'https://example.com'
raised me Net::HTTPFatalError
, with the following trace:
503 "Service Unavailable" (Net::HTTPFatalError)
/usr/local/lib/ruby/3.2.0/net/http/response.rb:258:in `error!'
/usr/local/lib/ruby/3.2.0/net/http/response.rb:267:in `value'
/usr/local/lib/ruby/3.2.0/net/http.rb:1293:in `connect'
/usr/local/lib/ruby/3.2.0/net/http.rb:1248:in `do_start'
/usr/local/lib/ruby/3.2.0/net/http.rb:1243:in `start'
/usr/local/bundle/gems/net-http-persistent-4.0.1/lib/net/http/persistent.rb:655:in `start'
/usr/local/bundle/gems/net-http-persistent-4.0.1/lib/net/http/persistent.rb:595:in `connection_for'
/usr/local/bundle/gems/net-http-persistent-4.0.1/lib/net/http/persistent.rb:885:in `request'
/usr/local/bundle/gems/mechanize-2.8.5/lib/mechanize/http/agent.rb:284:in `fetch'
/usr/local/bundle/gems/mechanize-2.8.5/lib/mechanize.rb:465:in `get'
/app/domain/my_example_script.rb:35:in `get_page'
In other occasions, the same agent.get
line raised me a normal Mechanize::ResponseCodeError
. I believe this case happened when response was completed, while the the previously mentioned exception happened during the connection phase of the fetch.
from mechanize.
@adrianodennanni Again, ResponseCodeError
is only intended to be used when a response has been successfully read, and the status code is surprising.
An exception related to networking should not be rescued by Mechanize -- in this case, the exception raised by Net::HTTP is what is raised. I think this is behaving as intended.
I'm happy to continue the conversation if you like -- I'm going to convert it to a Discussion.
from mechanize.
Related Issues (20)
- when down loading should start with https//sparkle motion/joshuamitchem mechanize HOT 2
- What's the RIGHT way to accomplish controlling the source IP and port with Mechanize?
- Heroku Stack and OpenSSL security HOT 3
- Hack to fix the "unsafe legacy renegotiation disabled" error
- Error 403 on heroku HOT 1
- wikipedia_links_to_philosophy.rb currently broken HOT 3
- Trouble when having so much li tags? HOT 1
- libxml2 2.11.x emitting error "FATAL: input conversion failed due to input error" on encoding errors HOT 2
- Per instance OpenSSL params set
- Vite Dev server crachses due to a circular reference in a symlink
- explore: mechanize failures when running with libxml2 head HOT 2
- Feature request: print a warning if you call `Form#submit` without specifying a `button` if there are multiple HOT 1
- `Mechanize::File` overrides the `File` base class HOT 3
- 403 error on scrapper but website is accessible on browser
- Add nkf as dependency for Ruby 3.4 support HOT 3
- Compatibility Inquiry: mechanize 2.10.0 with Ruby 3.3.0 HOT 4
- A
- ruby-head test failures related to the HTTP::Cookie API
- [Documentation] More examples? Specifically for imgur + ruby.
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 mechanize.