Class: SSE::HTTPConnectionFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/sse_client/streaming_http.rb

Overview

Used internally to send the HTTP request, including the proxy dialogue if necessary.

Class Method Summary collapse

Class Method Details

.connect(uri, proxy, connect_timeout, read_timeout) ⇒ Object



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/sse_client/streaming_http.rb', line 57

def self.connect(uri, proxy, connect_timeout, read_timeout)
  if !proxy
    return open_socket(uri, connect_timeout)
  end

  socket = open_socket(proxy, connect_timeout)
  socket.write(build_proxy_request(uri, proxy))

  # temporarily create a reader just for the proxy connect response
  proxy_reader = HTTPResponseReader.new(socket, read_timeout)
  if proxy_reader.status != 200
    raise ProxyError, "proxy connection refused, status #{proxy_reader.status}"
  end

  # start using TLS at this point if appropriate
  if uri.scheme.downcase == 'https'
    wrap_socket_in_ssl_socket(socket)
  else
    socket
  end
end