rack-proxy 0.3.4 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
data/Readme CHANGED
@@ -23,3 +23,5 @@ class Foo < Rack::Proxy
23
23
  end
24
24
 
25
25
  See tests for more examples.
26
+
27
+ WARNING: Doesn't work with fakeweb/webmock. Both libraries monkey-patch net/http code.
@@ -14,7 +14,7 @@
14
14
  #
15
15
  # Also, in Ruby 1.9.2 you could use Fibers to avoid hacking net/http.
16
16
 
17
- require 'net/http'
17
+ require 'net/https'
18
18
 
19
19
  class Net::HTTP
20
20
  # Original #request with block semantics.
@@ -4,6 +4,8 @@ module Rack
4
4
 
5
5
  # Wraps the hacked net/http in a Rack way.
6
6
  class HttpStreamingResponse
7
+ attr_accessor :use_ssl
8
+
7
9
  def initialize(request, host, port = nil)
8
10
  @request, @host, @port = request, host, port
9
11
  end
@@ -54,7 +56,11 @@ module Rack
54
56
 
55
57
  # Net::HTTP
56
58
  def session
57
- @session ||= Net::HTTP.start(@host, @port)
59
+ @session ||= begin
60
+ http = Net::HTTP.new @host, @port
61
+ http.use_ssl = self.use_ssl
62
+ http.start
63
+ end
58
64
  end
59
65
 
60
66
  end
data/lib/rack/proxy.rb CHANGED
@@ -5,7 +5,7 @@ module Rack
5
5
 
6
6
  # Subclass and bring your own #rewrite_request and #rewrite_response
7
7
  class Proxy
8
- VERSION = "0.3.4"
8
+ VERSION = "0.3.5"
9
9
 
10
10
  def call(env)
11
11
  rewrite_response(perform_request(rewrite_env(env)))
@@ -41,6 +41,8 @@ module Rack
41
41
 
42
42
  # Create a streaming response (the actual network communication is deferred, a.k.a. streamed)
43
43
  target_response = HttpStreamingResponse.new(target_request, source_request.host, source_request.port)
44
+
45
+ target_response.use_ssl = "https" == source_request.scheme
44
46
 
45
47
  [target_response.status, target_response.headers, target_response.body]
46
48
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-proxy
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
5
- prerelease: false
4
+ hash: 25
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 4
10
- version: 0.3.4
9
+ - 5
10
+ version: 0.3.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jacek Becela
@@ -15,8 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-11-04 00:00:00 +01:00
19
- default_executable:
18
+ date: 2012-01-09 00:00:00 Z
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
21
  name: rack
@@ -70,7 +69,6 @@ files:
70
69
  - test/net_http_hacked_test.rb
71
70
  - test/rack_proxy_test.rb
72
71
  - test/test_helper.rb
73
- has_rdoc: true
74
72
  homepage: http://rubygems.org/gems/rack-proxy
75
73
  licenses: []
76
74
 
@@ -100,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
100
98
  requirements: []
101
99
 
102
100
  rubyforge_project: rack-proxy
103
- rubygems_version: 1.3.7
101
+ rubygems_version: 1.8.10
104
102
  signing_key:
105
103
  specification_version: 3
106
104
  summary: A request/response rewriting HTTP proxy. A Rack app.