Permalink
Browse files

Merge proxy: {type: :connect} and {type: :http}

  • Loading branch information...
ConradIrwin committed Jun 14, 2013
1 parent 27bac89 commit 2dfd9d6edcc65c19491ab2ef1538e27fe1492c1a
Showing with 7 additions and 7 deletions.
  1. +2 −2 lib/em-http/http_connection_options.rb
  2. +5 −5 spec/connectify_proxy_spec.rb
@@ -31,11 +31,11 @@ def initialize(uri, options)
end
def http_proxy?
- @proxy && (@proxy[:type] == :http || @proxy[:type].nil? && !@https)
+ @proxy && (@proxy[:type] == :http || @proxy[:type].nil?) && !@https
end
def connect_proxy?
- @proxy && (@proxy[:type] == :connect || @proxy[:type].nil? && @https)
+ @proxy && (@proxy[:type] == :http || @proxy[:type].nil?) && @https
end
def socks_proxy?
@@ -4,12 +4,12 @@
requires_port(3128) do
describe EventMachine::HttpRequest do
- let(:connect_proxy) { {:proxy => { :host => '127.0.0.1', :port => 3128, :type => :connect }} }
- let(:default_proxy) { {:proxy => { :host => '127.0.0.1', :port => 3128, }} }
+ let(:http_proxy) { {:proxy => { :host => '127.0.0.1', :port => 3128, :type => :http }} }
+ let(:default_proxy) { {:proxy => { :host => '127.0.0.1', :port => 3128 }} }
- it "should use CONNECT proxy when specified" do
+ it "should use CONNECT proxy for HTTPS requests when :http specified" do
EventMachine.run {
- http = EventMachine::HttpRequest.new('http://jsonip.com/', connect_proxy).get
+ http = EventMachine::HttpRequest.new('https://ipjson.herokuapp.com/', http_proxy).get
http.errback { failed(http) }
http.callback {
@@ -20,7 +20,7 @@
}
end
- it "should use CONNECT proxy by default for HTTPS requests" do
+ it "should use CONNECT proxy for HTTPS when no type specified" do
EventMachine.run {
http = EventMachine::HttpRequest.new('https://ipjson.herokuapp.com/', default_proxy).get

0 comments on commit 2dfd9d6

Please sign in to comment.