Class: Proxifier::HTTPProxy

Inherits:
Proxy
  • Object
show all
Defined in:
lib/proxifier/proxies/http.rb

Instance Attribute Summary

Attributes inherited from Proxy

#options, #url

Instance Method Summary collapse

Methods inherited from Proxy

#initialize, #open, #proxify, #proxify?, proxify?, #query_options

Constructor Details

This class inherits a constructor from Proxifier::Proxy

Instance Method Details

#do_proxify(socket, host, port) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/proxifier/proxies/http.rb', line 6

def do_proxify(socket, host, port)
  return if query_options["tunnel"] == "false"

  socket << "CONNECT #{host}:#{port} HTTP/1.1\r\n"
  socket << "Host: #{host}:#{port}\r\n"
  socket << "Proxy-Authorization: Basic #{["#{user}:#{password}"].pack("m").chomp}\r\n" if user
  socket << "\r\n"

  buffer = Net::BufferedIO.new(socket)
  response = Net::HTTPResponse.read_new(buffer)
  response.error! unless response.is_a?(Net::HTTPOK)
end