Sha256: c8c1ceaee3f93e3474c54056188e412d78f919cf4a8be3df2f09c869164bad7a

Contents?: true

Size: 635 Bytes

Versions: 1

Compression:

Stored size: 635 Bytes

Contents

require "net/http"
require "proxifier/proxy"

module Proxifier
  class HTTPProxy < Proxy
    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 << "User-Agent: #{user_agent}\r\n" if user_agent
      socket << "\r\n"

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
proxifier-fork-1.0.4 lib/proxifier/proxies/http.rb