excon 0.80.1 → 0.81.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/lib/excon/connection.rb +19 -26
- data/lib/excon/constants.rb +1 -0
- data/lib/excon/instrumentors/logging_instrumentor.rb +1 -1
- data/lib/excon/ssl_socket.rb +4 -0
- data/lib/excon/utils.rb +17 -0
- data/lib/excon/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: faa033f8191dff08e7476d47c1771112a841d7c4e762462afd069dedfdfc0a48
|
4
|
+
data.tar.gz: ade28a41a3ea482d33620df5902c17b6c8909d3e8348d60241e8e43925136015
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 52ec74ebab2ab0057eaaa30255f73771088b70046df1478d0383f50e3067c73f5a3f33dbc9b6c8029df8f69d2e1104404bd032be113ca089b997ee5da63132fc
|
7
|
+
data.tar.gz: 9ec35940b326afae1467d00a29c17cc4ab003bc92701400251a44ec91f8961a1156152fab4219e5f1556eb3b5f06fc32613f5d553ceab04172f185c024f6dac3
|
data/lib/excon/connection.rb
CHANGED
@@ -115,7 +115,7 @@ module Excon
|
|
115
115
|
# we already have data from a middleware, so bail
|
116
116
|
return datum
|
117
117
|
else
|
118
|
-
socket
|
118
|
+
socket(datum)
|
119
119
|
# start with "METHOD /path"
|
120
120
|
request = datum[:method].to_s.upcase + ' '
|
121
121
|
if datum[:proxy] && datum[:scheme] != HTTPS
|
@@ -144,35 +144,25 @@ module Excon
|
|
144
144
|
end
|
145
145
|
|
146
146
|
# add headers to request
|
147
|
-
datum[:headers]
|
148
|
-
if key.to_s.match(/[\r\n]/)
|
149
|
-
raise Excon::Errors::InvalidHeaderKey.new(key.to_s.inspect + ' contains forbidden "\r" or "\n"')
|
150
|
-
end
|
151
|
-
[values].flatten.each do |value|
|
152
|
-
if value.to_s.match(/[\r\n]/)
|
153
|
-
raise Excon::Errors::InvalidHeaderValue.new(value.to_s.inspect + ' contains forbidden "\r" or "\n"')
|
154
|
-
end
|
155
|
-
request << key.to_s << ': ' << value.to_s << CR_NL
|
156
|
-
end
|
157
|
-
end
|
147
|
+
request << Utils.headers_hash_to_s(datum[:headers])
|
158
148
|
|
159
149
|
# add additional "\r\n" to indicate end of headers
|
160
150
|
request << CR_NL
|
161
151
|
|
162
152
|
if datum.has_key?(:request_block)
|
163
|
-
socket.write(request) # write out request + headers
|
153
|
+
socket(datum).write(request) # write out request + headers
|
164
154
|
while true # write out body with chunked encoding
|
165
155
|
chunk = datum[:request_block].call
|
166
156
|
chunk = binary_encode(chunk)
|
167
157
|
if chunk.length > 0
|
168
|
-
socket.write(chunk.length.to_s(16) << CR_NL << chunk << CR_NL)
|
158
|
+
socket(datum).write(chunk.length.to_s(16) << CR_NL << chunk << CR_NL)
|
169
159
|
else
|
170
|
-
socket.write(String.new("0#{CR_NL}#{CR_NL}"))
|
160
|
+
socket(datum).write(String.new("0#{CR_NL}#{CR_NL}"))
|
171
161
|
break
|
172
162
|
end
|
173
163
|
end
|
174
164
|
elsif body.nil?
|
175
|
-
socket.write(request) # write out request + headers
|
165
|
+
socket(datum).write(request) # write out request + headers
|
176
166
|
else # write out body
|
177
167
|
if body.respond_to?(:binmode) && !body.is_a?(StringIO)
|
178
168
|
body.binmode
|
@@ -186,13 +176,13 @@ module Excon
|
|
186
176
|
chunk = body.read([datum[:chunk_size] - request.length, 0].max)
|
187
177
|
if chunk
|
188
178
|
chunk = binary_encode(chunk)
|
189
|
-
socket.write(request << chunk)
|
179
|
+
socket(datum).write(request << chunk)
|
190
180
|
else
|
191
|
-
socket.write(request) # write out request + headers
|
181
|
+
socket(datum).write(request) # write out request + headers
|
192
182
|
end
|
193
183
|
|
194
184
|
while (chunk = body.read(datum[:chunk_size]))
|
195
|
-
socket.write(chunk)
|
185
|
+
socket(datum).write(chunk)
|
196
186
|
end
|
197
187
|
end
|
198
188
|
end
|
@@ -463,14 +453,14 @@ module Excon
|
|
463
453
|
end
|
464
454
|
end
|
465
455
|
|
466
|
-
def socket
|
467
|
-
unix_proxy =
|
468
|
-
sockets[@socket_key] ||= if
|
469
|
-
Excon::UnixSocket.new(
|
470
|
-
elsif
|
471
|
-
Excon::SSLSocket.new(
|
456
|
+
def socket(datum = @data)
|
457
|
+
unix_proxy = datum[:proxy] ? datum[:proxy][:scheme] == UNIX : false
|
458
|
+
sockets[@socket_key] ||= if datum[:scheme] == UNIX || unix_proxy
|
459
|
+
Excon::UnixSocket.new(datum)
|
460
|
+
elsif datum[:ssl_uri_schemes].include?(datum[:scheme])
|
461
|
+
Excon::SSLSocket.new(datum)
|
472
462
|
else
|
473
|
-
Excon::Socket.new(
|
463
|
+
Excon::Socket.new(datum)
|
474
464
|
end
|
475
465
|
end
|
476
466
|
|
@@ -573,6 +563,9 @@ module Excon
|
|
573
563
|
if uri.user
|
574
564
|
@data[:proxy][:user] = uri.user
|
575
565
|
end
|
566
|
+
if @data[:ssl_proxy_headers] && !@data[:ssl_uri_schemes].include?(@data[:scheme])
|
567
|
+
raise ArgumentError, "The `:ssl_proxy_headers` parameter should only be used with HTTPS requests."
|
568
|
+
end
|
576
569
|
if @data[:proxy][:scheme] == UNIX
|
577
570
|
if @data[:proxy][:host]
|
578
571
|
raise ArgumentError, "The `:host` parameter should not be set for `unix://` proxies.\n" +
|
data/lib/excon/constants.rb
CHANGED
data/lib/excon/ssl_socket.rb
CHANGED
@@ -104,6 +104,10 @@ module Excon
|
|
104
104
|
|
105
105
|
request += "Proxy-Connection: Keep-Alive#{Excon::CR_NL}"
|
106
106
|
|
107
|
+
if @data[:ssl_proxy_headers]
|
108
|
+
request << Utils.headers_hash_to_s(@data[:ssl_proxy_headers])
|
109
|
+
end
|
110
|
+
|
107
111
|
request += Excon::CR_NL
|
108
112
|
|
109
113
|
# write out the proxy setup request
|
data/lib/excon/utils.rb
CHANGED
@@ -121,5 +121,22 @@ module Excon
|
|
121
121
|
str.gsub!(/\+/, ' ')
|
122
122
|
str.gsub(ESCAPED) { $1.hex.chr }
|
123
123
|
end
|
124
|
+
|
125
|
+
# Performs validation on the passed header hash and returns a string representation of the headers
|
126
|
+
def headers_hash_to_s(headers)
|
127
|
+
headers_str = String.new
|
128
|
+
headers.each do |key, values|
|
129
|
+
if key.to_s.match(/[\r\n]/)
|
130
|
+
raise Excon::Errors::InvalidHeaderKey.new(key.to_s.inspect + ' contains forbidden "\r" or "\n"')
|
131
|
+
end
|
132
|
+
[values].flatten.each do |value|
|
133
|
+
if value.to_s.match(/[\r\n]/)
|
134
|
+
raise Excon::Errors::InvalidHeaderValue.new(value.to_s.inspect + ' contains forbidden "\r" or "\n"')
|
135
|
+
end
|
136
|
+
headers_str << key.to_s << ': ' << value.to_s << CR_NL
|
137
|
+
end
|
138
|
+
end
|
139
|
+
headers_str
|
140
|
+
end
|
124
141
|
end
|
125
142
|
end
|
data/lib/excon/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: excon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.81.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- dpiddy (Dan Peterson)
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2021-04-
|
13
|
+
date: 2021-04-28 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rspec
|
@@ -265,7 +265,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
265
265
|
- !ruby/object:Gem::Version
|
266
266
|
version: '0'
|
267
267
|
requirements: []
|
268
|
-
rubygems_version: 3.
|
268
|
+
rubygems_version: 3.2.15
|
269
269
|
signing_key:
|
270
270
|
specification_version: 4
|
271
271
|
summary: speed, persistence, http(s)
|