excon 0.92.4 → 0.110.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CONTRIBUTORS.md +182 -140
- data/README.md +66 -27
- data/data/cacert.pem +410 -289
- data/excon.gemspec +1 -1
- data/lib/excon/connection.rb +23 -5
- data/lib/excon/constants.rb +33 -24
- data/lib/excon/response.rb +13 -0
- data/lib/excon/socket.rb +135 -23
- data/lib/excon/ssl_socket.rb +17 -1
- data/lib/excon/test/server.rb +0 -2
- data/lib/excon/version.rb +2 -1
- data/lib/excon.rb +18 -7
- metadata +4 -18
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 02c669c6654fe1baab80a1a55bc0a2d2b40a64360f3d95d77ef79b59315f879a
|
|
4
|
+
data.tar.gz: '0759c4b45586f33258913b23ffb9b649cf40848816537f57763be8922ecc2b0b'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1d25f9b6551303983b04114bf9fa2d27e7a3ad06bcfa8cc2295fe8b8afd04142f103ce02d4969b7f06af5c10465c343921a12543dd348787a348b9ca150f30c9
|
|
7
|
+
data.tar.gz: 3db2e11eae51f277b7a22ab3daa2505ea836098f6789001e580354f29706e5b6f1cd063cbab772ac6811186f0a8af955dd26029a17b15ea5a5b79d14285ba7b6
|
data/CONTRIBUTORS.md
CHANGED
|
@@ -1,140 +1,182 @@
|
|
|
1
|
-
* Aaron Stone
|
|
2
|
-
* Adam
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|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
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
*
|
|
1
|
+
* Aaron Stone
|
|
2
|
+
* Adam Avilla
|
|
3
|
+
* Adam Esterline
|
|
4
|
+
* Alexander Sandström
|
|
5
|
+
* Alexandr Burov
|
|
6
|
+
* Andrew Katz
|
|
7
|
+
* Andrew Metcalf
|
|
8
|
+
* Andrew Sullivan Cant
|
|
9
|
+
* André Diego Piske
|
|
10
|
+
* Andy Delcambre
|
|
11
|
+
* Anshul Khandelwal
|
|
12
|
+
* Anton Chuchkalov
|
|
13
|
+
* Antonio Terceiro
|
|
14
|
+
* Ash Wilson
|
|
15
|
+
* Atul Bhosale
|
|
16
|
+
* Bart de Water
|
|
17
|
+
* Ben Burkert
|
|
18
|
+
* Benedikt Böhm
|
|
19
|
+
* Bill Mill
|
|
20
|
+
* Bo Jeanes
|
|
21
|
+
* Brandur
|
|
22
|
+
* Brian D. Burns
|
|
23
|
+
* Brian Hartsock
|
|
24
|
+
* Bryan Paxton
|
|
25
|
+
* Caio Chassot
|
|
26
|
+
* Caius Durling
|
|
27
|
+
* Carl Hörberg
|
|
28
|
+
* Carl Hörberg
|
|
29
|
+
* Carlos Sanchez
|
|
30
|
+
* Casper Thomsen
|
|
31
|
+
* Chris Hanks
|
|
32
|
+
* Christoph Rieß
|
|
33
|
+
* Christophe Taton
|
|
34
|
+
* Claudio Poli
|
|
35
|
+
* Craig Shannon
|
|
36
|
+
* Damien Mathieu
|
|
37
|
+
* Dan Hensgen
|
|
38
|
+
* Dan Peterson
|
|
39
|
+
* Dan Prince
|
|
40
|
+
* Dane Harrigan
|
|
41
|
+
* Daniel Berger
|
|
42
|
+
* Dave Myron
|
|
43
|
+
* Dave Newton
|
|
44
|
+
* Dave Vasilevsky
|
|
45
|
+
* David Biehl
|
|
46
|
+
* David Taylor
|
|
47
|
+
* Dimitrij Denissenko
|
|
48
|
+
* Dominik Richter
|
|
49
|
+
* Doug McInnes
|
|
50
|
+
* Esteban Pastorino
|
|
51
|
+
* Eugene Howe
|
|
52
|
+
* Evan Phoenix
|
|
53
|
+
* Fabian Wiesel
|
|
54
|
+
* Federico Ravasio
|
|
55
|
+
* Felix Wolfsteller
|
|
56
|
+
* Glenn Pratt
|
|
57
|
+
* Graeme Nelson
|
|
58
|
+
* Grey Baker
|
|
59
|
+
* Guillaume Balaine
|
|
60
|
+
* Hakan Ensari
|
|
61
|
+
* Hiroshi Hatake
|
|
62
|
+
* Ian Neubert
|
|
63
|
+
* Igor Fedoronchuk
|
|
64
|
+
* Jacob Atzen
|
|
65
|
+
* James Cox
|
|
66
|
+
* James Watling
|
|
67
|
+
* Jean Mertz
|
|
68
|
+
* Jeremy Hinegardner
|
|
69
|
+
* Jesse Kempf
|
|
70
|
+
* Jessica Jiang
|
|
71
|
+
* Joe Rafaniello
|
|
72
|
+
* John Keiser
|
|
73
|
+
* John Leach
|
|
74
|
+
* Jonas Pfenniger
|
|
75
|
+
* Jonathan Dance
|
|
76
|
+
* Jonathan Roes
|
|
77
|
+
* Joshua B. Smith
|
|
78
|
+
* Joshua Gross
|
|
79
|
+
* Joshua Mckinney
|
|
80
|
+
* Joshua Napoli
|
|
81
|
+
* Kelly Mahan
|
|
82
|
+
* Kensuke Nagae
|
|
83
|
+
* Kimmo Lehto
|
|
84
|
+
* Koen Rouwhorst
|
|
85
|
+
* Konstantin Shabanov
|
|
86
|
+
* Kyle Purkiss
|
|
87
|
+
* Kyle Rames
|
|
88
|
+
* Lewis Marshall
|
|
89
|
+
* Lincoln Stoll
|
|
90
|
+
* Louis Sobel
|
|
91
|
+
* Mahemoff
|
|
92
|
+
* Marco Costa
|
|
93
|
+
* Markus Bucher
|
|
94
|
+
* Mathias Meyer
|
|
95
|
+
* Matt Gauger
|
|
96
|
+
* Matt Palmer
|
|
97
|
+
* Matt Sanders
|
|
98
|
+
* Matt Snyder
|
|
99
|
+
* Matt Todd
|
|
100
|
+
* Maurice Schreiber
|
|
101
|
+
* Max Lincoln
|
|
102
|
+
* Michael Brodhead
|
|
103
|
+
* Michael Hale
|
|
104
|
+
* Michael Rowe
|
|
105
|
+
* Michael Rykov
|
|
106
|
+
* Mike Heffner
|
|
107
|
+
* Milovan Zogovic
|
|
108
|
+
* Myron Marston
|
|
109
|
+
* Nathan Long
|
|
110
|
+
* Nathan Sutton
|
|
111
|
+
* Nick Osborn
|
|
112
|
+
* Nicolas Leger
|
|
113
|
+
* Nicolas Sanguinetti
|
|
114
|
+
* Paul Gideon Dann
|
|
115
|
+
* Pavel
|
|
116
|
+
* Pavel Valena
|
|
117
|
+
* Peter Meier
|
|
118
|
+
* Peter Weldon
|
|
119
|
+
* Phil Ross
|
|
120
|
+
* Raul Murciano
|
|
121
|
+
* Richard Godbee
|
|
122
|
+
* Richard Ramsden
|
|
123
|
+
* Rohan Mendon
|
|
124
|
+
* Ruslan Korolev
|
|
125
|
+
* Ruslan Kyrychuk
|
|
126
|
+
* Ryan Bigg
|
|
127
|
+
* Ryan Mohr
|
|
128
|
+
* Ryan Schlesinger
|
|
129
|
+
* Ryoji Yoshioka
|
|
130
|
+
* Sam
|
|
131
|
+
* Sam Lehman
|
|
132
|
+
* Sam Withrow
|
|
133
|
+
* Scott Gonyea
|
|
134
|
+
* Scott Walkinshaw
|
|
135
|
+
* Sean Cribbs
|
|
136
|
+
* Sergio Rubio
|
|
137
|
+
* Shai Rosenfeld
|
|
138
|
+
* Stan Hu
|
|
139
|
+
* Stefan Merettig
|
|
140
|
+
* Stephen Chu
|
|
141
|
+
* Swanand Pagnis
|
|
142
|
+
* Terry Howe
|
|
143
|
+
* Thom Mahoney & Josh Lane
|
|
144
|
+
* Thom May
|
|
145
|
+
* Tim Carey-Smith
|
|
146
|
+
* Timothée Peignier
|
|
147
|
+
* Tobias Schmidt
|
|
148
|
+
* Todd Lunter
|
|
149
|
+
* Tom Maher
|
|
150
|
+
* Trym Skaar
|
|
151
|
+
* Tuomas Silen
|
|
152
|
+
* Victor Costan
|
|
153
|
+
* Viven
|
|
154
|
+
* Vít Ondruch
|
|
155
|
+
* Wesley Beary
|
|
156
|
+
* Yusuke Nakamura
|
|
157
|
+
* Zach Anker
|
|
158
|
+
* chrisrhoden
|
|
159
|
+
* dependabot[bot]
|
|
160
|
+
* dickeyxxx
|
|
161
|
+
* geemus
|
|
162
|
+
* geemus (Wesley Beary)
|
|
163
|
+
* ggoodale
|
|
164
|
+
* ivan.filenko
|
|
165
|
+
* jasquat
|
|
166
|
+
* karimb
|
|
167
|
+
* marios
|
|
168
|
+
* mkb
|
|
169
|
+
* nathannaveen
|
|
170
|
+
* ojab
|
|
171
|
+
* patrick brisbin
|
|
172
|
+
* pavel
|
|
173
|
+
* phiggins
|
|
174
|
+
* rin_ne
|
|
175
|
+
* rinrinne
|
|
176
|
+
* rkyrychuk
|
|
177
|
+
* shale
|
|
178
|
+
* sshaw
|
|
179
|
+
* starbelly
|
|
180
|
+
* twrodriguez
|
|
181
|
+
* wsnarski
|
|
182
|
+
* zimbatm
|
data/README.md
CHANGED
|
@@ -4,8 +4,8 @@ Usable, fast, simple Ruby HTTP 1.1
|
|
|
4
4
|
|
|
5
5
|
Excon was designed to be simple, fast and performant. It works great as a general HTTP(s) client and is particularly well suited to usage in API clients.
|
|
6
6
|
|
|
7
|
-
[](https://
|
|
7
|
+
[](https://github.com/excon/excon/actions/workflows/ci.yml)
|
|
8
|
+
[](https://rubygems.org/gems/excon)
|
|
9
9
|
|
|
10
10
|
- [Getting Started](#getting-started)
|
|
11
11
|
- [Options](#options)
|
|
@@ -127,6 +127,38 @@ connection.request(:method => 'GET')
|
|
|
127
127
|
# expect one or more status codes, or raise an error
|
|
128
128
|
connection.request(:expects => [200, 201], :method => :get)
|
|
129
129
|
|
|
130
|
+
# use basic authentication by supplying credentials in the URL or as parameters
|
|
131
|
+
connection = Excon.new('http://username:password@secure.geemus.com')
|
|
132
|
+
# Note: username & password is unescaped for request, so you should provide escaped values here
|
|
133
|
+
# i. e. instead of `password: 'pa%%word'` you should use `password: Excon::Utils.escape_uri('pa%%word')`,
|
|
134
|
+
# which return `pa%25%25word`
|
|
135
|
+
connection = Excon.new('http://secure.geemus.com',
|
|
136
|
+
:user => 'username', :password => 'password')
|
|
137
|
+
|
|
138
|
+
# use custom uri parser
|
|
139
|
+
require 'addressable/uri'
|
|
140
|
+
connection = Excon.new('http://geemus.com/', uri_parser: Addressable::URI)
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Compared to web browsers and other http client libraries, e.g. curl, Excon is a bit more low-level and doesn't assume much by default. If you are seeing different results compared to other clients, the following options might help:
|
|
144
|
+
|
|
145
|
+
```ruby
|
|
146
|
+
# opt-in to omitting port from http:80 and https:443
|
|
147
|
+
connection = Excon.new('http://geemus.com/', :omit_default_port => true)
|
|
148
|
+
|
|
149
|
+
# accept gzip encoding
|
|
150
|
+
connection = Excon.new('http://geemus.com/', :headers => { "Accept-Encoding" => "gzip" })
|
|
151
|
+
|
|
152
|
+
# turn off peer verification (less secure)
|
|
153
|
+
Excon.defaults[:ssl_verify_peer] = false
|
|
154
|
+
connection = Excon.new('https://...')
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## Timeouts and Retries
|
|
158
|
+
|
|
159
|
+
You can modify timeouts and define whether and how many (blocking) retries Excon should attempt if errors occur.
|
|
160
|
+
|
|
161
|
+
```ruby
|
|
130
162
|
# this request can be repeated safely, so retry on errors up to 4 times
|
|
131
163
|
connection.request(:idempotent => true)
|
|
132
164
|
|
|
@@ -137,12 +169,20 @@ connection.request(:idempotent => true, :retry_limit => 6)
|
|
|
137
169
|
# in between each retry
|
|
138
170
|
connection.request(:idempotent => true, :retry_limit => 6, :retry_interval => 5)
|
|
139
171
|
|
|
172
|
+
# specify the errors on which to retry (default Timeout, Socket, HTTPStatus)
|
|
173
|
+
# only retry on timeouts
|
|
174
|
+
connection.request(:idempotent => true, :retry_limit => 6, :retry_interval => 5, :retry_errors => [Excon::Error::Timeout] )
|
|
175
|
+
|
|
140
176
|
# set longer read_timeout (default is 60 seconds)
|
|
141
177
|
connection.request(:read_timeout => 360)
|
|
142
178
|
|
|
143
179
|
# set longer write_timeout (default is 60 seconds)
|
|
144
180
|
connection.request(:write_timeout => 360)
|
|
145
181
|
|
|
182
|
+
# set a request timeout in seconds (default is no timeout).
|
|
183
|
+
# the timeout may be an integer or a float to support sub-second granularity (e.g., 1, 60, 0.005 and 3.5).
|
|
184
|
+
connection.request(:timeout => 0.1) # timeout if the entire request takes longer than 100 milliseconds
|
|
185
|
+
|
|
146
186
|
# Enable the socket option TCP_NODELAY on the underlying socket.
|
|
147
187
|
#
|
|
148
188
|
# This can improve response time when sending frequent short
|
|
@@ -156,31 +196,20 @@ connection = Excon.new('http://geemus.com/', :connect_timeout => 360)
|
|
|
156
196
|
# opt-out of nonblocking operations for performance and/or as a workaround
|
|
157
197
|
connection = Excon.new('http://geemus.com/', :nonblock => false)
|
|
158
198
|
|
|
159
|
-
#
|
|
160
|
-
|
|
161
|
-
#
|
|
162
|
-
#
|
|
163
|
-
|
|
164
|
-
connection = Excon.new('http://secure.geemus.com',
|
|
165
|
-
:user => 'username', :password => 'password')
|
|
199
|
+
# DEPRECATED in favour of `resolv_resolver` (see below)
|
|
200
|
+
# set up desired dns_timeouts for resolving addresses (default is set by Resolv)
|
|
201
|
+
# it accepts an integer or an array of integers for retrying with different timeouts
|
|
202
|
+
# see Resolv::DNS#timeouts for more details (https://ruby-doc.org/3.2.2/stdlibs/resolv/Resolv/DNS.html#method-i-timeouts-3D)
|
|
203
|
+
connection = Excon.new('http://geemus.com/', :dns_timeouts => 3)
|
|
166
204
|
|
|
167
|
-
#
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
# opt-in to omitting port from http:80 and https:443
|
|
176
|
-
connection = Excon.new('http://geemus.com/', :omit_default_port => true)
|
|
177
|
-
|
|
178
|
-
# accept gzip encoding
|
|
179
|
-
connection = Excon.new('http://geemus.com/', :headers => { "Accept-Encoding" => "gzip" })
|
|
180
|
-
|
|
181
|
-
# turn off peer verification (less secure)
|
|
182
|
-
Excon.defaults[:ssl_verify_peer] = false
|
|
183
|
-
connection = Excon.new('https://...')
|
|
205
|
+
# set a custom resolver for Resolv
|
|
206
|
+
# you can use custom nameservers and timeouts
|
|
207
|
+
# `timeouts` accepts an integer or an array of integers for retrying with different timeouts
|
|
208
|
+
# see Resolv::DNS#timeouts for more details (https://ruby-doc.org/3.2.2/stdlibs/resolv/Resolv/DNS.html#method-i-timeouts-3D)
|
|
209
|
+
dns_resolver = Resolv::DNS.new(nameserver: ['127.0.0.1'])
|
|
210
|
+
dns_resolver.timeouts = 3
|
|
211
|
+
resolver = Resolv.new([Resolv::Hosts.new, dns_resolver])
|
|
212
|
+
connection = Excon.new('http://geemus.com', :resolv_resolver => resolver)
|
|
184
213
|
```
|
|
185
214
|
|
|
186
215
|
## Chunked Requests
|
|
@@ -436,7 +465,16 @@ connection = Excon.new('https://example.com',
|
|
|
436
465
|
|
|
437
466
|
`client_key_pass` is optional.
|
|
438
467
|
|
|
439
|
-
|
|
468
|
+
Optionally, you can also pass the whole chain by passing the extra certificates through `client_chain`:
|
|
469
|
+
|
|
470
|
+
```ruby
|
|
471
|
+
connection = Excon.new('https://example.com',
|
|
472
|
+
client_cert: 'mycert.pem',
|
|
473
|
+
client_chain: 'mychain.pem',
|
|
474
|
+
client_key: 'mycert.key')
|
|
475
|
+
```
|
|
476
|
+
|
|
477
|
+
If you already have loaded the certificate, key and chain into memory, then pass it through like:
|
|
440
478
|
|
|
441
479
|
```ruby
|
|
442
480
|
client_cert_data = File.load 'mycert.pem'
|
|
@@ -444,6 +482,7 @@ client_key_data = File.load 'mycert.key'
|
|
|
444
482
|
|
|
445
483
|
connection = Excon.new('https://example.com',
|
|
446
484
|
client_cert_data: client_cert_data,
|
|
485
|
+
client_chain_data: client_chain_data,
|
|
447
486
|
client_key_data: client_key_data)
|
|
448
487
|
```
|
|
449
488
|
|