68 Commits

Author SHA1 Message Date
Brandon Dunne
923f90558c Prefer #hostname over #host. (#714) 2017-07-26 15:40:46 +01:00
Mattia
f994b054f9 Support adapter customization (#651)
* add initializer on Faraday::Adapter that accept and store a block with custom configuration
use the `@ config_block ` block on `net_http` and `net_http_persistent` adapters
added tests

* fixes warning in tests
patron was supporting custom block already! Small refactoring to conform to other adapters

* added implementation for httpclient
excon and EM adapters now all support `connection_options` in the initializer

* additional test for httpclient adapter
2017-01-13 12:07:01 +00:00
Mattia Giuffrida
3e0feb2f1b fixes #630
Rescue IOError rather than EOFError to cover more exceptions
2016-11-22 12:14:50 +00:00
Nick Prokesch
bfc1563c2c Update net_http.rb (#594)
Add recognition of uncaught `Errno::EPIPE: Broken pipe` error to `NET_HTTP_EXCEPTIONS`
2016-10-27 10:27:08 +01:00
Leon Miller-Out
a38ba7a13b Adds reason phrase support (#547)
* Adds a `#reason_phrase` method to the Response class
Implements the reason phrase for the Net::Http adapter ONLY

* Reason phrase support for the Excon adapter

This assumes that the reason phrase is also implemented into the
Excon project

* Implement reason phrase for patron, httpclient, em_http, em_synchrony adapters.

* Don't test for reason phrase with Rack adapter, which doesn't make it available.

* Don't test for reason phrase support in Typhoeus adapter.

* Make reason_phrase nil in adapters that don't support it (instead of "")
2016-08-24 17:43:19 +01:00
Ricardo Valeriano
f73d13ee09 Wrap Errno::ETIMEDOUT in Faraday::Error::TimeoutError
Closes #324
2015-10-06 16:32:03 +02:00
Mislav Marohnić
faf501b277 Fix default port numbers for Net::HTTP adapters
When Addressable::URI is used, the `port` property will be nil unless
port was explicitly specified. This made Addressable unusable in HTTPS
scenarios with Net::HTTP adapters, which would default to port 80 even
when the scheme was "https".
2015-08-20 22:25:47 -07:00
Ben Maraney
c2f325a329 NetHttp uses with_net_http_connection (#446) 2015-01-04 10:19:31 +02:00
Mike Bourgeous
9ad0fcd38a Treat connection timeouts as connection failures in net-http adapter. 2014-11-13 17:41:48 -07:00
Erik Michaels-Ober
77c040476a rescue Errno::EHOSTUNREACH 2014-01-09 02:59:50 +01:00
Mislav Marohnić
4ac193943b wrap OpenSSL exceptions in Faraday's own SSLError class 2013-07-27 14:38:20 +02:00
Michael Ossareh
8d6d3bcf33 Handle the case of an unreachable network.
This can happen in a number of cases, a good example is when your stack
tries to make an IPv6 connection and it is not possible.
2012-12-11 17:21:50 -08:00
Erik Michaels-Ober
48ff65b764 Require zlib for Ruby 1.8
In Ruby 1.9, zlib is required by net/http but this is not the case in
Ruby 1.8, causing a NameError (uninitialized constant
Faraday::Adapter::NetHttp::Zlib).
2012-08-15 11:17:17 -04:00
Myron Marston
f41ffaabb7 Ensure empty body responses are consistently returned as empty strings.
Zero-byte response bodies can be represented as either nil or '' in ruby.
Most ruby HTTP clients use '' (which, conveniently, allows clients
to assume the body is always a string), but Net::HTTP, for whatever
reason, uses nil.

This change makes it so that all faraday adapters consistently return
'' for zero-byte response bodies.
2012-08-12 13:49:20 +02:00
Erik Michaels-Ober
2274fe2105 Add Zlib::GzipFile::Error to the list of errors that may be raised by net/http
Closes jnunemaker/twitter#276
2012-06-29 09:35:25 -06:00
David Lee
f54bb91274 Fix ssl_verify_mode
ssl_verify_mode was referencing http, which resulted in:
NameError: undefined local variable or method `http' for #<Faraday::Adapter::NetHttp:0x007fe8c2cc24e8>
2012-04-18 00:03:15 -07:00
Mislav Marohnić
e8118055d5 refactor NetHttp and NetHttpPersistent adapters
closes #133
2012-04-15 15:42:31 +02:00
rick
d68d862310 Merge pull request #129 from nbibler/net_http_exception_wrapping
Wrap known exceptions which bubble up through Net::HTTP
2012-04-14 08:24:00 -07:00
Dor Shahaf
5cbfd2cdbf Allow setting of ssl version 2012-04-11 20:03:50 +03:00
Nathaniel Bibler
3cb8fb21ff Wrap known exceptions which bubble up through Net::HTTP 2012-03-29 15:34:26 -04:00
Mislav Marohnić
86925fd5d5 eliminate Ruby warnings 2012-01-19 16:07:09 +01:00
Jiren Patel
6aecc5de6c enable GET requests with body for Net::HTTP adapter 2011-12-30 17:06:45 +01:00
Mislav Marohnić
8f7f6694da remove dependency on Addressable::URI
This is a potentially breaking change for 3rd party code that relies on
env[:url] being specifically Addressable. After this change all urls are
passed around as instances of URI::HTTP.
2011-12-30 15:08:14 +01:00
Mislav Marohnić
fdabbc1b29 fix HEAD requests with Net:HTTP
Net::HTTP on Ruby 1.9.3p0 would spend insane amount of time (~30s) per
request waiting to get response body from a HEAD request.
2011-12-29 01:56:56 +01:00
rick
ed64a91de4 test patron and net/http timeouts 2011-12-28 14:37:38 -07:00
Erik Michaels-Ober
4524cfafdc Cleanup trailing whitespace 2011-11-28 03:46:27 -08:00
James Tucker
209f07cb01 Use the default system CA certs if available 2011-08-25 23:40:17 -07:00
Mislav Marohnić
5dddbfb1fd correct the logic correction: ssl[:verify_mode]
Previous logic correction (70f3eb3) was in fact a breakage of functionality.
The ssl[:verify_mode] is not a boolean; it's the value that, if present,
should be passed directly to http.verify_mode
2011-08-09 20:03:57 +02:00
Todd Fisher
70f3eb3962 logic correction... 2011-08-07 18:11:30 -04:00
risk
11011acf43 allow setting ssl verify_depth with net/http 2011-06-12 14:10:05 -07:00
Alex Kremer
71c101b0eb Add ca_path to SSL options hash 2011-04-13 10:31:17 +08:00
Mislav Marohnić
b85e0a18df refactor how adapters save response params to env
Ensures :response_headers always get initialized

Closes #50
2011-04-04 20:06:32 +02:00
Mislav Marohnić
f739002d0b more love for response headers; handle ones with multiple values
Also:
  - ensure that env[:response_headers] is not available during request phase
  - fix headers from "Test" adapter

Closes #43
2011-03-27 21:57:14 +02:00
Mislav Marohnić
8dccfc6117 like :request_headers, env[:response_headers] is now case-insensitive 2011-03-27 00:23:20 +01:00
Mislav Marohnić
7d277ef563 fix HTTPS requests should go to port 443 if none specified 2011-03-26 21:25:17 +01:00
Greg Spurrier
a461c234cb Support :cert_store SSL option 2011-03-26 21:25:17 +01:00
Mislav Marohnić
ddc41641b2 make SSL peer verification as default. disable with connection.ssl[:verify] = false 2011-03-26 21:25:17 +01:00
Mislav Marohnić
c3e5b69507 ruby 1.9 compat when raising ConnectionFailed 2011-03-26 21:16:42 +01:00
Mislav Marohnić
8c5701f8ea enable net/http adapter to use gzip for GET
also get rid of `full_path_for`; replaced with `url.request_uri`
2011-03-26 21:16:42 +01:00
Dave Yeu & Tim Gildea
cef0152af8 Fixes rescue block for refused connections, just for Net::HTTP 2011-01-13 09:29:37 +08:00
Daniel Cadenas
87baca6cf5 Fix typo 2011-01-13 09:29:36 +08:00
Erik Michaels-Ober
bfae62f840 Cleanup EOL whitespace 2010-10-08 12:33:09 -07:00
rick
ca5ec52b71 help ruby disambiguate the constants 2010-10-05 11:46:13 -07:00
rick
647c8fe6e1 merge 2010-10-05 11:19:22 -07:00
rick
44dfe35f02 Faraday exceptions shouldn't shadow real exceptions 2010-10-05 10:27:47 -07:00
rick
6007c76efa yay, net/http can stream like nobody's business 2010-09-07 15:45:10 -07:00
rick
12b519aedc add multipart support 2010-09-07 15:12:18 -07:00
rick
51a004ebc2 refactor common Faraday adapter methods into a Faraday::Adapter middleware 2010-09-07 12:05:36 -07:00
rick
a43e0896a6 add http proxy support to net/http 2010-04-27 09:53:33 -04:00
rick
7739157945 add ssl support to net/http and typhoeus 2010-04-27 09:35:17 -04:00