Skip to content

Commit

Permalink
Merge proxy: {type: :connect} and {type: :http}
Browse files Browse the repository at this point in the history
  • Loading branch information
ConradIrwin committed Jun 14, 2013
1 parent 27bac89 commit 2dfd9d6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions lib/em-http/http_connection_options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
10 changes: 5 additions & 5 deletions spec/connectify_proxy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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

Expand Down

0 comments on commit 2dfd9d6

Please sign in to comment.