Class: HTTP::Timeout::Null
- Inherits:
-
Object
- Object
- HTTP::Timeout::Null
- Extended by:
- Forwardable
- 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
-
#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.
15 16 17 |
# File 'lib/http/timeout/null.rb', line 15 def initialize( = {}) @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
13 14 15 |
# File 'lib/http/timeout/null.rb', line 13 def @options end |
#socket ⇒ Object (readonly)
Returns the value of attribute socket.
13 14 15 |
# File 'lib/http/timeout/null.rb', line 13 def socket @socket end |
Instance Method Details
#connect(socket_class, host, port, nodelay = false) ⇒ Object
Connects to a socket
20 21 22 23 |
# File 'lib/http/timeout/null.rb', line 20 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
26 27 28 |
# File 'lib/http/timeout/null.rb', line 26 def connect_ssl @socket.connect end |
#readpartial(size, buffer = nil) ⇒ Object
Read from the socket
45 46 47 48 49 |
# File 'lib/http/timeout/null.rb', line 45 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
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/http/timeout/null.rb', line 31 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
52 53 54 |
# File 'lib/http/timeout/null.rb', line 52 def write(data) @socket.write(data) end |