Sha256: 7171383c2d7c340c59f079aac2afd36a718ec9fcc3116374fb0bf351841699cc

Contents?: true

Size: 573 Bytes

Versions: 5

Compression:

Stored size: 573 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 << "\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

5 entries across 5 versions & 2 rubygems

Version Path
proxifier2-1.1.0 lib/proxifier/proxies/http.rb
proxifier-1.0.3 lib/proxifier/proxies/http.rb
proxifier-1.0.2 lib/proxifier/proxies/http.rb
proxifier-1.0.1 lib/proxifier/proxies/http.rb
proxifier-1.0.0 lib/proxifier/proxies/http.rb