Class: HTTPX::SSL
Constant Summary
collapse
- TLS_OPTIONS =
if OpenSSL::SSL::SSLContext.instance_methods.include?(:alpn_protocols)
{ alpn_protocols: %w[h2 http/1.1] }
else
{}
end
Instance Attribute Summary
Attributes inherited from TCP
#ip, #port
Instance Method Summary
collapse
Methods inherited from TCP
#closed?, #connected?, #to_io
Methods included from Loggable
#log
Constructor Details
#initialize(_, _, options) ⇒ SSL
150
151
152
153
154
155
156
|
# File 'lib/httpx/io.rb', line 150
def initialize(_, _, options)
@ctx = OpenSSL::SSL::SSLContext.new
ctx_options = TLS_OPTIONS.merge(options.ssl)
@ctx.set_params(ctx_options) unless ctx_options.empty?
super
@state = :negotiated if @keep_open
end
|
Instance Method Details
#close ⇒ Object
168
169
170
171
172
173
174
|
# File 'lib/httpx/io.rb', line 168
def close
super
@io = @io.io if @io.respond_to?(:io)
@negotiated = false
end
|
#connect ⇒ Object
176
177
178
179
180
181
182
183
184
185
186
187
188
189
|
# File 'lib/httpx/io.rb', line 176
def connect
super
if @keep_open
@state = :negotiated
return
end
return if @state == :negotiated ||
@state != :connected
@io = OpenSSL::SSL::SSLSocket.new(@io, @ctx)
@io.hostname = @hostname
@io.sync_close = true
@io.connect
transition(:negotiated)
end
|
#inspect ⇒ Object
217
218
219
220
|
# File 'lib/httpx/io.rb', line 217
def inspect
id = @io.closed? ? "closed" : @io.to_io.fileno
"#<SSL(fd: #{id}): #{@ip}:#{@port} state: #{@state}>"
end
|
#protocol ⇒ Object
162
163
164
165
166
|
# File 'lib/httpx/io.rb', line 162
def protocol
@io.alpn_protocol || super
rescue StandardError
super
end
|
#read(size, buffer) ⇒ Object
192
193
194
195
196
|
# File 'lib/httpx/io.rb', line 192
def read(*)
super
rescue ::IO::WaitWritable
0
end
|
#scheme ⇒ Object
158
159
160
|
# File 'lib/httpx/io.rb', line 158
def scheme
"https"
end
|
#write ⇒ Object
198
199
200
201
202
|
# File 'lib/httpx/io.rb', line 198
def write(*)
super
rescue ::IO::WaitReadable
0
end
|