Class: HTTP::Timeout::Null

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/http/timeout/null.rb

Direct Known Subclasses

PerOperation

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Null

Returns a new instance of Null


12
13
14
# File 'lib/http/timeout/null.rb', line 12

def initialize(options = {})
  @options = options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options


10
11
12
# File 'lib/http/timeout/null.rb', line 10

def options
  @options
end

#socketObject (readonly)

Returns the value of attribute socket


10
11
12
# File 'lib/http/timeout/null.rb', line 10

def socket
  @socket
end

Instance Method Details

#connect(socket_class, host, port) ⇒ Object

Connects to a socket


17
18
19
# File 'lib/http/timeout/null.rb', line 17

def connect(socket_class, host, port)
  @socket = socket_class.open(host, port)
end

#connect_sslObject

Starts a SSL connection on a socket


22
23
24
# File 'lib/http/timeout/null.rb', line 22

def connect_ssl
  @socket.connect
end

#readpartial(size) ⇒ Object

Read from the socket


40
41
42
43
44
# File 'lib/http/timeout/null.rb', line 40

def readpartial(size)
  @socket.readpartial(size)
rescue EOFError
  :eof
end

#start_tls(host, ssl_socket_class, ssl_context) ⇒ Object

Configures the SSL connection and starts the connection


27
28
29
30
31
32
33
34
35
36
37
# File 'lib/http/timeout/null.rb', line 27

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

  @socket.post_connection_check(host)
end

#write(data) ⇒ Object Also known as: <<

Write to the socket


47
48
49
# File 'lib/http/timeout/null.rb', line 47

def write(data)
  @socket.write(data)
end