httpx 0.20.0 → 1.3.1
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/LICENSE.txt +0 -48
- data/README.md +54 -45
- data/doc/release_notes/0_10_0.md +2 -2
- data/doc/release_notes/0_11_0.md +3 -5
- data/doc/release_notes/0_12_0.md +5 -5
- data/doc/release_notes/0_13_0.md +5 -5
- data/doc/release_notes/0_14_0.md +2 -2
- data/doc/release_notes/0_16_0.md +3 -3
- data/doc/release_notes/0_17_0.md +1 -1
- data/doc/release_notes/0_18_0.md +4 -4
- data/doc/release_notes/0_18_2.md +1 -1
- data/doc/release_notes/0_19_0.md +1 -1
- data/doc/release_notes/0_19_8.md +1 -1
- data/doc/release_notes/0_20_0.md +2 -2
- data/doc/release_notes/0_20_1.md +5 -0
- data/doc/release_notes/0_20_2.md +7 -0
- data/doc/release_notes/0_20_3.md +6 -0
- data/doc/release_notes/0_20_4.md +17 -0
- data/doc/release_notes/0_20_5.md +3 -0
- data/doc/release_notes/0_21_0.md +96 -0
- data/doc/release_notes/0_21_1.md +12 -0
- data/doc/release_notes/0_22_0.md +13 -0
- data/doc/release_notes/0_22_1.md +11 -0
- data/doc/release_notes/0_22_2.md +5 -0
- data/doc/release_notes/0_22_3.md +55 -0
- data/doc/release_notes/0_22_4.md +6 -0
- data/doc/release_notes/0_22_5.md +6 -0
- data/doc/release_notes/0_23_0.md +42 -0
- data/doc/release_notes/0_23_1.md +5 -0
- data/doc/release_notes/0_23_2.md +5 -0
- data/doc/release_notes/0_23_3.md +6 -0
- data/doc/release_notes/0_23_4.md +5 -0
- data/doc/release_notes/0_24_0.md +48 -0
- data/doc/release_notes/0_24_1.md +12 -0
- data/doc/release_notes/0_24_2.md +12 -0
- data/doc/release_notes/0_24_3.md +12 -0
- data/doc/release_notes/0_24_4.md +18 -0
- data/doc/release_notes/0_24_5.md +6 -0
- data/doc/release_notes/0_24_6.md +5 -0
- data/doc/release_notes/0_24_7.md +10 -0
- data/doc/release_notes/1_0_0.md +60 -0
- data/doc/release_notes/1_0_1.md +5 -0
- data/doc/release_notes/1_0_2.md +7 -0
- data/doc/release_notes/1_1_0.md +32 -0
- data/doc/release_notes/1_1_1.md +17 -0
- data/doc/release_notes/1_1_2.md +12 -0
- data/doc/release_notes/1_1_3.md +18 -0
- data/doc/release_notes/1_1_4.md +6 -0
- data/doc/release_notes/1_1_5.md +12 -0
- data/doc/release_notes/1_2_0.md +49 -0
- data/doc/release_notes/1_2_1.md +6 -0
- data/doc/release_notes/1_2_2.md +10 -0
- data/doc/release_notes/1_2_3.md +16 -0
- data/doc/release_notes/1_2_4.md +8 -0
- data/doc/release_notes/1_2_5.md +7 -0
- data/doc/release_notes/1_2_6.md +13 -0
- data/doc/release_notes/1_3_0.md +18 -0
- data/doc/release_notes/1_3_1.md +17 -0
- data/lib/httpx/adapters/datadog.rb +215 -122
- data/lib/httpx/adapters/faraday.rb +145 -107
- data/lib/httpx/adapters/sentry.rb +26 -7
- data/lib/httpx/adapters/webmock.rb +34 -18
- data/lib/httpx/altsvc.rb +63 -26
- data/lib/httpx/base64.rb +27 -0
- data/lib/httpx/buffer.rb +12 -0
- data/lib/httpx/callbacks.rb +5 -3
- data/lib/httpx/chainable.rb +54 -39
- data/lib/httpx/connection/http1.rb +75 -44
- data/lib/httpx/connection/http2.rb +31 -38
- data/lib/httpx/connection.rb +287 -117
- data/lib/httpx/domain_name.rb +10 -13
- data/lib/httpx/errors.rb +52 -2
- data/lib/httpx/extensions.rb +24 -131
- data/lib/httpx/io/ssl.rb +83 -77
- data/lib/httpx/io/tcp.rb +48 -71
- data/lib/httpx/io/udp.rb +18 -52
- data/lib/httpx/io/unix.rb +10 -15
- data/lib/httpx/io.rb +3 -9
- data/lib/httpx/loggable.rb +4 -19
- data/lib/httpx/options.rb +176 -118
- data/lib/httpx/parser/http1.rb +4 -0
- data/lib/httpx/plugins/{authentication → auth}/basic.rb +1 -5
- data/lib/httpx/plugins/{authentication → auth}/digest.rb +14 -14
- data/lib/httpx/plugins/{authentication → auth}/ntlm.rb +1 -3
- data/lib/httpx/plugins/{authentication → auth}/socks5.rb +0 -2
- data/lib/httpx/plugins/auth.rb +25 -0
- data/lib/httpx/plugins/aws_sdk_authentication.rb +4 -3
- data/lib/httpx/plugins/aws_sigv4.rb +12 -9
- data/lib/httpx/plugins/basic_auth.rb +29 -0
- data/lib/httpx/plugins/brotli.rb +50 -0
- data/lib/httpx/plugins/callbacks.rb +91 -0
- data/lib/httpx/plugins/circuit_breaker/circuit.rb +100 -0
- data/lib/httpx/plugins/circuit_breaker/circuit_store.rb +53 -0
- data/lib/httpx/plugins/circuit_breaker.rb +148 -0
- data/lib/httpx/plugins/cookies/set_cookie_parser.rb +0 -2
- data/lib/httpx/plugins/cookies.rb +30 -17
- data/lib/httpx/plugins/{digest_authentication.rb → digest_auth.rb} +14 -12
- data/lib/httpx/plugins/expect.rb +21 -14
- data/lib/httpx/plugins/follow_redirects.rb +140 -41
- data/lib/httpx/plugins/grpc/call.rb +2 -3
- data/lib/httpx/plugins/grpc/grpc_encoding.rb +88 -0
- data/lib/httpx/plugins/grpc/message.rb +7 -37
- data/lib/httpx/plugins/grpc.rb +36 -29
- data/lib/httpx/plugins/h2c.rb +26 -19
- data/lib/httpx/plugins/internal_telemetry.rb +16 -0
- data/lib/httpx/plugins/{ntlm_authentication.rb → ntlm_auth.rb} +7 -5
- data/lib/httpx/plugins/oauth.rb +175 -0
- data/lib/httpx/plugins/persistent.rb +1 -1
- data/lib/httpx/plugins/proxy/http.rb +23 -13
- data/lib/httpx/plugins/proxy/socks4.rb +9 -7
- data/lib/httpx/plugins/proxy/socks5.rb +11 -9
- data/lib/httpx/plugins/proxy.rb +80 -61
- data/lib/httpx/plugins/push_promise.rb +1 -1
- data/lib/httpx/plugins/rate_limiter.rb +5 -1
- data/lib/httpx/plugins/response_cache/file_store.rb +40 -0
- data/lib/httpx/plugins/response_cache/store.rb +62 -25
- data/lib/httpx/plugins/response_cache.rb +105 -12
- data/lib/httpx/plugins/retries.rb +87 -17
- data/lib/httpx/plugins/ssrf_filter.rb +145 -0
- data/lib/httpx/plugins/stream.rb +27 -23
- data/lib/httpx/plugins/upgrade/h2.rb +4 -4
- data/lib/httpx/plugins/upgrade.rb +8 -10
- data/lib/httpx/plugins/webdav.rb +80 -0
- data/lib/httpx/pool/synch_pool.rb +93 -0
- data/lib/httpx/pool.rb +102 -27
- data/lib/httpx/punycode.rb +9 -291
- data/lib/httpx/request/body.rb +154 -0
- data/lib/httpx/request.rb +130 -146
- data/lib/httpx/resolver/https.rb +62 -27
- data/lib/httpx/resolver/multi.rb +9 -13
- data/lib/httpx/resolver/native.rb +192 -76
- data/lib/httpx/resolver/resolver.rb +34 -9
- data/lib/httpx/resolver/system.rb +16 -11
- data/lib/httpx/resolver.rb +38 -16
- data/lib/httpx/response/body.rb +242 -0
- data/lib/httpx/response/buffer.rb +96 -0
- data/lib/httpx/response.rb +159 -217
- data/lib/httpx/selector.rb +9 -4
- data/lib/httpx/session.rb +137 -89
- data/lib/httpx/session_extensions.rb +4 -1
- data/lib/httpx/timers.rb +34 -8
- data/lib/httpx/transcoder/body.rb +0 -2
- data/lib/httpx/transcoder/chunker.rb +0 -1
- data/lib/httpx/transcoder/deflate.rb +37 -0
- data/lib/httpx/transcoder/form.rb +52 -33
- data/lib/httpx/transcoder/gzip.rb +74 -0
- data/lib/httpx/transcoder/json.rb +21 -8
- data/lib/httpx/transcoder/multipart/decoder.rb +139 -0
- data/lib/httpx/{plugins → transcoder}/multipart/encoder.rb +4 -4
- data/lib/httpx/{plugins → transcoder}/multipart/mime_type_detector.rb +1 -1
- data/lib/httpx/{plugins → transcoder}/multipart/part.rb +3 -2
- data/lib/httpx/transcoder/multipart.rb +17 -0
- data/lib/httpx/transcoder/utils/body_reader.rb +46 -0
- data/lib/httpx/transcoder/utils/deflater.rb +72 -0
- data/lib/httpx/transcoder/utils/inflater.rb +19 -0
- data/lib/httpx/transcoder/xml.rb +52 -0
- data/lib/httpx/transcoder.rb +5 -6
- data/lib/httpx/utils.rb +36 -16
- data/lib/httpx/version.rb +1 -1
- data/lib/httpx.rb +12 -14
- data/sig/altsvc.rbs +33 -0
- data/sig/buffer.rbs +2 -1
- data/sig/callbacks.rbs +3 -3
- data/sig/chainable.rbs +11 -9
- data/sig/connection/http1.rbs +8 -7
- data/sig/connection/http2.rbs +19 -19
- data/sig/connection.rbs +64 -24
- data/sig/errors.rbs +22 -3
- data/sig/httpx.rbs +5 -4
- data/sig/io/ssl.rbs +27 -0
- data/sig/io/tcp.rbs +60 -0
- data/sig/io/udp.rbs +20 -0
- data/sig/io/unix.rbs +27 -0
- data/sig/io.rbs +6 -0
- data/sig/options.rbs +32 -22
- data/sig/parser/http1.rbs +1 -1
- data/sig/plugins/{authentication → auth}/basic.rbs +0 -2
- data/sig/plugins/{authentication → auth}/digest.rbs +2 -1
- data/sig/plugins/auth.rbs +13 -0
- data/sig/plugins/{basic_authentication.rbs → basic_auth.rbs} +2 -2
- data/sig/plugins/brotli.rbs +22 -0
- data/sig/plugins/callbacks.rbs +38 -0
- data/sig/plugins/circuit_breaker.rbs +71 -0
- data/sig/plugins/compression.rbs +7 -5
- data/sig/plugins/cookies/jar.rbs +2 -2
- data/sig/plugins/cookies.rbs +2 -0
- data/sig/plugins/{digest_authentication.rbs → digest_auth.rbs} +2 -2
- data/sig/plugins/follow_redirects.rbs +18 -4
- data/sig/plugins/grpc/call.rbs +19 -0
- data/sig/plugins/grpc/grpc_encoding.rbs +37 -0
- data/sig/plugins/grpc/message.rbs +17 -0
- data/sig/plugins/grpc.rbs +7 -32
- data/sig/plugins/h2c.rbs +1 -1
- data/sig/plugins/{ntlm_authentication.rbs → ntlm_auth.rbs} +2 -2
- data/sig/plugins/oauth.rbs +54 -0
- data/sig/plugins/proxy/http.rbs +3 -0
- data/sig/plugins/proxy/socks4.rbs +9 -6
- data/sig/plugins/proxy/socks5.rbs +10 -6
- data/sig/plugins/proxy/ssh.rbs +1 -1
- data/sig/plugins/proxy.rbs +13 -5
- data/sig/plugins/push_promise.rbs +3 -3
- data/sig/plugins/rate_limiter.rbs +1 -1
- data/sig/plugins/response_cache.rbs +36 -7
- data/sig/plugins/retries.rbs +30 -8
- data/sig/plugins/stream.rbs +24 -17
- data/sig/plugins/upgrade.rbs +5 -3
- data/sig/pool.rbs +10 -7
- data/sig/request/body.rbs +38 -0
- data/sig/request.rbs +15 -24
- data/sig/resolver/https.rbs +8 -3
- data/sig/resolver/native.rbs +17 -4
- data/sig/resolver/resolver.rbs +8 -6
- data/sig/resolver/system.rbs +2 -0
- data/sig/resolver.rbs +9 -5
- data/sig/response/body.rbs +53 -0
- data/sig/response/buffer.rbs +24 -0
- data/sig/response.rbs +24 -39
- data/sig/selector.rbs +1 -1
- data/sig/session.rbs +29 -18
- data/sig/timers.rbs +18 -8
- data/sig/transcoder/body.rbs +4 -3
- data/sig/transcoder/deflate.rbs +11 -0
- data/sig/transcoder/form.rbs +5 -3
- data/sig/transcoder/gzip.rbs +24 -0
- data/sig/transcoder/json.rbs +8 -3
- data/sig/{plugins → transcoder}/multipart.rbs +15 -19
- data/sig/transcoder/utils/body_reader.rbs +15 -0
- data/sig/transcoder/utils/deflater.rbs +29 -0
- data/sig/transcoder/utils/inflater.rbs +12 -0
- data/sig/transcoder/xml.rbs +22 -0
- data/sig/transcoder.rbs +24 -9
- data/sig/utils.rbs +8 -2
- metadata +163 -41
- data/lib/httpx/plugins/authentication.rb +0 -20
- data/lib/httpx/plugins/basic_authentication.rb +0 -30
- data/lib/httpx/plugins/compression/brotli.rb +0 -54
- data/lib/httpx/plugins/compression/deflate.rb +0 -49
- data/lib/httpx/plugins/compression/gzip.rb +0 -88
- data/lib/httpx/plugins/compression.rb +0 -164
- data/lib/httpx/plugins/multipart/decoder.rb +0 -187
- data/lib/httpx/plugins/multipart.rb +0 -84
- data/lib/httpx/registry.rb +0 -85
- data/sig/plugins/authentication.rbs +0 -11
- data/sig/plugins/compression/brotli.rbs +0 -21
- data/sig/plugins/compression/deflate.rbs +0 -17
- data/sig/plugins/compression/gzip.rbs +0 -29
- data/sig/registry.rbs +0 -12
- /data/sig/plugins/{authentication → auth}/ntlm.rbs +0 -0
- /data/sig/plugins/{authentication → auth}/socks5.rbs +0 -0
data/lib/httpx/io/tcp.rb
CHANGED
@@ -17,7 +17,7 @@ module HTTPX
|
|
17
17
|
@state = :idle
|
18
18
|
@addresses = []
|
19
19
|
@hostname = origin.host
|
20
|
-
@options =
|
20
|
+
@options = options
|
21
21
|
@fallback_protocol = @options.fallback_protocol
|
22
22
|
@port = origin.port
|
23
23
|
@interests = :w
|
@@ -38,7 +38,10 @@ module HTTPX
|
|
38
38
|
add_addresses(addresses)
|
39
39
|
end
|
40
40
|
@ip_index = @addresses.size - 1
|
41
|
-
|
41
|
+
end
|
42
|
+
|
43
|
+
def socket
|
44
|
+
@io
|
42
45
|
end
|
43
46
|
|
44
47
|
def add_addresses(addrs)
|
@@ -74,7 +77,9 @@ module HTTPX
|
|
74
77
|
try_connect
|
75
78
|
rescue Errno::ECONNREFUSED,
|
76
79
|
Errno::EADDRNOTAVAIL,
|
77
|
-
Errno::EHOSTUNREACH
|
80
|
+
Errno::EHOSTUNREACH,
|
81
|
+
SocketError,
|
82
|
+
IOError => e
|
78
83
|
raise e if @ip_index <= 0
|
79
84
|
|
80
85
|
log { "failed connecting to #{@ip} (#{e.message}), trying next..." }
|
@@ -90,84 +95,45 @@ module HTTPX
|
|
90
95
|
retry
|
91
96
|
end
|
92
97
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
@interests = :w
|
99
|
-
rescue ::IO::WaitReadable
|
98
|
+
def try_connect
|
99
|
+
ret = @io.connect_nonblock(Socket.sockaddr_in(@port, @ip.to_s), exception: false)
|
100
|
+
log(level: 3, color: :cyan) { "TCP CONNECT: #{ret}..." }
|
101
|
+
case ret
|
102
|
+
when :wait_readable
|
100
103
|
@interests = :r
|
101
|
-
|
102
|
-
|
103
|
-
@interests = :w
|
104
|
-
else
|
105
|
-
transition(:connected)
|
104
|
+
return
|
105
|
+
when :wait_writable
|
106
106
|
@interests = :w
|
107
|
+
return
|
107
108
|
end
|
108
|
-
|
109
|
+
transition(:connected)
|
110
|
+
@interests = :w
|
111
|
+
rescue Errno::EALREADY
|
112
|
+
@interests = :w
|
113
|
+
end
|
114
|
+
private :try_connect
|
109
115
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
buffer.bytesize
|
114
|
-
rescue ::IO::WaitReadable
|
116
|
+
def read(size, buffer)
|
117
|
+
ret = @io.read_nonblock(size, buffer, exception: false)
|
118
|
+
if ret == :wait_readable
|
115
119
|
buffer.clear
|
116
|
-
0
|
117
|
-
rescue EOFError
|
118
|
-
nil
|
119
|
-
end
|
120
|
-
|
121
|
-
def write(buffer)
|
122
|
-
siz = @io.write_nonblock(buffer)
|
123
|
-
log { "WRITE: #{siz} bytes..." }
|
124
|
-
buffer.shift!(siz)
|
125
|
-
siz
|
126
|
-
rescue ::IO::WaitWritable
|
127
|
-
0
|
128
|
-
rescue EOFError
|
129
|
-
nil
|
130
|
-
end
|
131
|
-
# :nocov:
|
132
|
-
else
|
133
|
-
def try_connect
|
134
|
-
case @io.connect_nonblock(Socket.sockaddr_in(@port, @ip.to_s), exception: false)
|
135
|
-
when :wait_readable
|
136
|
-
@interests = :r
|
137
|
-
return
|
138
|
-
when :wait_writable
|
139
|
-
@interests = :w
|
140
|
-
return
|
141
|
-
end
|
142
|
-
transition(:connected)
|
143
|
-
@interests = :w
|
144
|
-
rescue Errno::EALREADY
|
145
|
-
@interests = :w
|
120
|
+
return 0
|
146
121
|
end
|
147
|
-
|
148
|
-
|
149
|
-
def read(size, buffer)
|
150
|
-
ret = @io.read_nonblock(size, buffer, exception: false)
|
151
|
-
if ret == :wait_readable
|
152
|
-
buffer.clear
|
153
|
-
return 0
|
154
|
-
end
|
155
|
-
return if ret.nil?
|
122
|
+
return if ret.nil?
|
156
123
|
|
157
|
-
|
158
|
-
|
159
|
-
|
124
|
+
log { "READ: #{buffer.bytesize} bytes..." }
|
125
|
+
buffer.bytesize
|
126
|
+
end
|
160
127
|
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
128
|
+
def write(buffer)
|
129
|
+
siz = @io.write_nonblock(buffer, exception: false)
|
130
|
+
return 0 if siz == :wait_writable
|
131
|
+
return if siz.nil?
|
165
132
|
|
166
|
-
|
133
|
+
log { "WRITE: #{siz} bytes..." }
|
167
134
|
|
168
|
-
|
169
|
-
|
170
|
-
end
|
135
|
+
buffer.shift!(siz)
|
136
|
+
siz
|
171
137
|
end
|
172
138
|
|
173
139
|
def close
|
@@ -188,6 +154,17 @@ module HTTPX
|
|
188
154
|
@state == :idle || @state == :closed
|
189
155
|
end
|
190
156
|
|
157
|
+
def expired?
|
158
|
+
# do not mess with external sockets
|
159
|
+
return false if @options.io
|
160
|
+
|
161
|
+
return true unless @addresses
|
162
|
+
|
163
|
+
resolver_addresses = Resolver.nolookup_resolve(@hostname)
|
164
|
+
|
165
|
+
(Array(resolver_addresses) & @addresses).empty?
|
166
|
+
end
|
167
|
+
|
191
168
|
# :nocov:
|
192
169
|
def inspect
|
193
170
|
"#<#{self.class}: #{@ip}:#{@port} (state: #{@state})>"
|
data/lib/httpx/io/udp.rb
CHANGED
@@ -6,11 +6,10 @@ module HTTPX
|
|
6
6
|
class UDP
|
7
7
|
include Loggable
|
8
8
|
|
9
|
-
def initialize(
|
10
|
-
|
11
|
-
@
|
12
|
-
@
|
13
|
-
@io = UDPSocket.new(ip.family)
|
9
|
+
def initialize(ip, port, options)
|
10
|
+
@host = ip
|
11
|
+
@port = port
|
12
|
+
@io = UDPSocket.new(IPAddr.new(ip).family)
|
14
13
|
@options = options
|
15
14
|
end
|
16
15
|
|
@@ -24,45 +23,19 @@ module HTTPX
|
|
24
23
|
true
|
25
24
|
end
|
26
25
|
|
27
|
-
|
28
|
-
|
29
|
-
def close
|
30
|
-
@io.close
|
31
|
-
rescue StandardError
|
32
|
-
nil
|
33
|
-
end
|
34
|
-
# :nocov:
|
35
|
-
else
|
36
|
-
def close
|
37
|
-
@io.close
|
38
|
-
end
|
26
|
+
def close
|
27
|
+
@io.close
|
39
28
|
end
|
40
29
|
|
41
|
-
|
42
|
-
|
43
|
-
RUBY_VERSION < "2.3"
|
30
|
+
if RUBY_ENGINE == "jruby"
|
31
|
+
# In JRuby, sendmsg_nonblock is not implemented
|
44
32
|
def write(buffer)
|
45
|
-
siz = @io.
|
33
|
+
siz = @io.send(buffer.to_s, 0, @host, @port)
|
46
34
|
log { "WRITE: #{siz} bytes..." }
|
47
35
|
buffer.shift!(siz)
|
48
36
|
siz
|
49
|
-
rescue ::IO::WaitWritable
|
50
|
-
0
|
51
|
-
rescue EOFError
|
52
|
-
nil
|
53
|
-
end
|
54
|
-
|
55
|
-
def read(size, buffer)
|
56
|
-
data, _ = @io.recvfrom_nonblock(size)
|
57
|
-
buffer.replace(data)
|
58
|
-
log { "READ: #{buffer.bytesize} bytes..." }
|
59
|
-
buffer.bytesize
|
60
|
-
rescue ::IO::WaitReadable
|
61
|
-
0
|
62
|
-
rescue IOError
|
63
37
|
end
|
64
38
|
else
|
65
|
-
|
66
39
|
def write(buffer)
|
67
40
|
siz = @io.sendmsg_nonblock(buffer.to_s, 0, Socket.sockaddr_in(@port, @host.to_s), exception: false)
|
68
41
|
return 0 if siz == :wait_writable
|
@@ -73,24 +46,17 @@ module HTTPX
|
|
73
46
|
buffer.shift!(siz)
|
74
47
|
siz
|
75
48
|
end
|
49
|
+
end
|
76
50
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
51
|
+
def read(size, buffer)
|
52
|
+
ret = @io.recvfrom_nonblock(size, 0, buffer, exception: false)
|
53
|
+
return 0 if ret == :wait_readable
|
54
|
+
return if ret.nil?
|
81
55
|
|
82
|
-
|
83
|
-
rescue IOError
|
84
|
-
end
|
85
|
-
end
|
56
|
+
log { "READ: #{buffer.bytesize} bytes..." }
|
86
57
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
log { "WRITE: #{siz} bytes..." }
|
91
|
-
buffer.shift!(siz)
|
92
|
-
siz
|
93
|
-
end if RUBY_ENGINE == "jruby"
|
94
|
-
# :nocov:
|
58
|
+
buffer.bytesize
|
59
|
+
rescue IOError
|
60
|
+
end
|
95
61
|
end
|
96
62
|
end
|
data/lib/httpx/io/unix.rb
CHANGED
@@ -1,22 +1,18 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "forwardable"
|
4
|
-
|
5
3
|
module HTTPX
|
6
4
|
class UNIX < TCP
|
7
|
-
extend Forwardable
|
8
|
-
|
9
5
|
using URIExtensions
|
10
6
|
|
11
7
|
attr_reader :path
|
12
8
|
|
13
9
|
alias_method :host, :path
|
14
10
|
|
15
|
-
def initialize(origin,
|
16
|
-
@addresses =
|
11
|
+
def initialize(origin, path, options)
|
12
|
+
@addresses = []
|
17
13
|
@hostname = origin.host
|
18
14
|
@state = :idle
|
19
|
-
@options =
|
15
|
+
@options = options
|
20
16
|
@fallback_protocol = @options.fallback_protocol
|
21
17
|
if @options.io
|
22
18
|
@io = case @options.io
|
@@ -30,15 +26,10 @@ module HTTPX
|
|
30
26
|
@path = @io.path
|
31
27
|
@keep_open = true
|
32
28
|
@state = :connected
|
29
|
+
elsif path
|
30
|
+
@path = path
|
33
31
|
else
|
34
|
-
|
35
|
-
# :nocov:
|
36
|
-
warn ":#{__method__} is deprecated, use :addresses instead"
|
37
|
-
@path = @options.transport_options[:path]
|
38
|
-
# :nocov:
|
39
|
-
else
|
40
|
-
@path = addresses.first
|
41
|
-
end
|
32
|
+
raise Error, "No path given where to store the socket"
|
42
33
|
end
|
43
34
|
@io ||= build_socket
|
44
35
|
end
|
@@ -60,6 +51,10 @@ module HTTPX
|
|
60
51
|
::IO::WaitReadable
|
61
52
|
end
|
62
53
|
|
54
|
+
def expired?
|
55
|
+
false
|
56
|
+
end
|
57
|
+
|
63
58
|
# :nocov:
|
64
59
|
def inspect
|
65
60
|
"#<#{self.class}(path: #{@path}): (state: #{@state})>"
|
data/lib/httpx/io.rb
CHANGED
@@ -4,14 +4,8 @@ require "socket"
|
|
4
4
|
require "httpx/io/udp"
|
5
5
|
require "httpx/io/tcp"
|
6
6
|
require "httpx/io/unix"
|
7
|
-
require "httpx/io/ssl"
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
register "udp", UDP
|
13
|
-
register "unix", HTTPX::UNIX
|
14
|
-
register "tcp", TCP
|
15
|
-
register "ssl", SSL
|
16
|
-
end
|
8
|
+
begin
|
9
|
+
require "httpx/io/ssl"
|
10
|
+
rescue LoadError
|
17
11
|
end
|
data/lib/httpx/loggable.rb
CHANGED
@@ -24,26 +24,11 @@ module HTTPX
|
|
24
24
|
debug_stream << message
|
25
25
|
end
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
return unless @options.debug
|
31
|
-
return unless @options.debug_level >= level
|
32
|
-
|
33
|
-
log(level: level, color: color) { ex.full_message }
|
34
|
-
end
|
35
|
-
|
36
|
-
else
|
37
|
-
|
38
|
-
def log_exception(ex, level: @options.debug_level, color: nil)
|
39
|
-
return unless @options.debug
|
40
|
-
return unless @options.debug_level >= level
|
41
|
-
|
42
|
-
message = +"#{ex.message} (#{ex.class})"
|
43
|
-
message << "\n" << ex.backtrace.join("\n") unless ex.backtrace.nil?
|
44
|
-
log(level: level, color: color) { message }
|
45
|
-
end
|
27
|
+
def log_exception(ex, level: @options.debug_level, color: nil)
|
28
|
+
return unless @options.debug
|
29
|
+
return unless @options.debug_level >= level
|
46
30
|
|
31
|
+
log(level: level, color: color) { ex.full_message }
|
47
32
|
end
|
48
33
|
end
|
49
34
|
end
|