Sha256: 4f84c0c6f8da738d88ecd27088e54c2080128bf2d4ce529772d5fa7e1914761e

Contents?: true

Size: 1.66 KB

Versions: 10

Compression:

Stored size: 1.66 KB

Contents

require 'helper'

requires_connection do

  requires_port(8080) do
    describe EventMachine::HttpRequest do

      # ssh -D 8080 igvita
      let(:proxy) { {:proxy => { :host => '127.0.0.1', :port => 8080, :type => :socks5 }} }

      it "should use SOCKS5 proxy" do
        EventMachine.run {
          http = EventMachine::HttpRequest.new('http://jsonip.com/', proxy).get

          http.errback { failed(http) }
          http.callback {
            http.response_header.status.should == 200
            http.response.should match('173.230.151.99')
            EventMachine.stop
          }
        }
      end
    end
  end

  requires_port(8081) do
    describe EventMachine::HttpRequest do

      # brew install tinyproxy
      let(:http_proxy) { {:proxy => { :host => '127.0.0.1', :port => 8081 }} }

      it "should use HTTP proxy by default" do
        EventMachine.run {
          http = EventMachine::HttpRequest.new('http://jsonip.com/', http_proxy).get

          http.errback { failed(http) }
          http.callback {
            http.response_header.status.should == 200
            http.response.should match(/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/)
            EventMachine.stop
          }
        }
      end

      it "should auto CONNECT via HTTP proxy for HTTPS requests" do
        EventMachine.run {
          http = EventMachine::HttpRequest.new('https://ipjson.herokuapp.com/', http_proxy).get

          http.errback { failed(http) }
          http.callback {
            http.response_header.status.should == 200
            http.response.should match(/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/)
            EventMachine.stop
          }
        }
      end
    end
  end

end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
em-http-request-samesite-0.1.1 spec/socksify_proxy_spec.rb
em-http-request-samesite-1.1.7 spec/socksify_proxy_spec.rb
em-http-request-1.1.7 spec/socksify_proxy_spec.rb
em-http-request-1.1.6 spec/socksify_proxy_spec.rb
em-http-request-1.1.5 spec/socksify_proxy_spec.rb
em-http-request-1.1.4 spec/socksify_proxy_spec.rb
em-http-request-1.1.3 spec/socksify_proxy_spec.rb
em-http-request-1.1.2 spec/socksify_proxy_spec.rb
em-http-request-1.1.1 spec/socksify_proxy_spec.rb
em-http-request-1.1.0 spec/socksify_proxy_spec.rb