Class: HTTP::Timeout::Null
- Inherits:
-
Object
- Object
- HTTP::Timeout::Null
- Defined in:
- lib/http/timeout/null.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#socket ⇒ Object
readonly
Returns the value of attribute socket.
Instance Method Summary collapse
- #close ⇒ Object
- #closed? ⇒ Boolean
-
#connect(socket_class, host, port, nodelay = false) ⇒ Object
Connects to a socket.
-
#connect_ssl ⇒ Object
Starts a SSL connection on a socket.
-
#initialize(options = {}) ⇒ Null
constructor
A new instance of Null.
-
#readpartial(size, buffer = nil) ⇒ Object
Read from the socket.
-
#start_tls(host, ssl_socket_class, ssl_context) ⇒ Object
Configures the SSL connection and starts the connection.
-
#write(data) ⇒ Object
(also: #<<)
Write to the socket.
Constructor Details
#initialize(options = {}) ⇒ Null
Returns a new instance of Null.
10 11 12 |
# File 'lib/http/timeout/null.rb', line 10 def initialize( = {}) @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
8 9 10 |
# File 'lib/http/timeout/null.rb', line 8 def @options end |
#socket ⇒ Object (readonly)
Returns the value of attribute socket.
8 9 10 |
# File 'lib/http/timeout/null.rb', line 8 def socket @socket end |
Instance Method Details
#close ⇒ Object
25 26 27 |
# File 'lib/http/timeout/null.rb', line 25 def close @socket&.close end |
#closed? ⇒ Boolean
29 30 31 |
# File 'lib/http/timeout/null.rb', line 29 def closed? @socket&.closed? end |
#connect(socket_class, host, port, nodelay = false) ⇒ Object
Connects to a socket
15 16 17 18 |
# File 'lib/http/timeout/null.rb', line 15 def connect(socket_class, host, port, nodelay = false) @socket = socket_class.open(host, port) @socket.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1) if nodelay end |
#connect_ssl ⇒ Object
Starts a SSL connection on a socket
21 22 23 |
# File 'lib/http/timeout/null.rb', line 21 def connect_ssl @socket.connect end |
#readpartial(size, buffer = nil) ⇒ Object
Read from the socket
48 49 50 51 52 |
# File 'lib/http/timeout/null.rb', line 48 def readpartial(size, buffer = nil) @socket.readpartial(size, buffer) rescue EOFError :eof end |
#start_tls(host, ssl_socket_class, ssl_context) ⇒ Object
Configures the SSL connection and starts the connection
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/http/timeout/null.rb', line 34 def start_tls(host, ssl_socket_class, ssl_context) @socket = ssl_socket_class.new(socket, ssl_context) @socket.hostname = host if @socket.respond_to? :hostname= @socket.sync_close = true if @socket.respond_to? :sync_close= connect_ssl return unless ssl_context.verify_mode == OpenSSL::SSL::VERIFY_PEER return if ssl_context.respond_to?(:verify_hostname) && !ssl_context.verify_hostname @socket.post_connection_check(host) end |
#write(data) ⇒ Object Also known as: <<
Write to the socket
55 56 57 |
# File 'lib/http/timeout/null.rb', line 55 def write(data) @socket.write(data) end |