Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

cleanup HTTP(S) proxy support, bump gemspec to latest deps

  • Loading branch information...
commit 905c51fd5b3c0ef8c277ab49427da4d780146fdb 1 parent b8f26b3
@igrigorik igrigorik authored
View
7 em-http-request.gemspec
@@ -14,11 +14,10 @@ Gem::Specification.new do |s|
s.description = s.summary
s.rubyforge_project = "em-http-request"
- s.add_dependency "eventmachine", ">= 1.0.0.beta.4"
- s.add_dependency "addressable", ">= 2.2.3"
+ s.add_dependency "eventmachine", ">= 1.0.3"
+ s.add_dependency "addressable", ">= 2.3.4"
s.add_dependency "http_parser.rb", ">= 0.6.0.beta.2"
- s.add_dependency "em-socksify"
- s.add_dependency "em-connectify", ">= 0.2"
+ s.add_dependency "em-socksify", ">= 0.3"
s.add_dependency "cookiejar"
s.add_development_dependency "rspec"
View
1  lib/em-http.rb
@@ -1,6 +1,5 @@
require 'eventmachine'
require 'em-socksify'
-require 'em-connectify'
require 'addressable/uri'
require 'http/parser'
View
37 spec/connectify_proxy_spec.rb
@@ -1,37 +0,0 @@
-require 'helper'
-
-requires_connection do
- requires_port(3128) do
- describe EventMachine::HttpRequest do
-
- 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 for HTTPS requests when :http specified" 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('173.230.151.99')
- EventMachine.stop
- }
- }
- end
-
- 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
-
- 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
-end
View
36 spec/socksify_proxy_spec.rb
@@ -1,6 +1,7 @@
require 'helper'
requires_connection do
+
requires_port(8080) do
describe EventMachine::HttpRequest do
@@ -21,4 +22,39 @@
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
Please sign in to comment.
Something went wrong with that request. Please try again.