rack-proxy 0.5.17 → 0.5.18

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 911c88bd0398ee9c1436b3d056dcf5ae349d2e6e
4
- data.tar.gz: 8851932d2467e42eff3b464f4b0865f30b846ed8
3
+ metadata.gz: 1a10a4faae0e96b439f6603d90dccbed07d49d4c
4
+ data.tar.gz: e0fbc5485768ec3772650081ac608d4494aa65b2
5
5
  SHA512:
6
- metadata.gz: 376239211b8ea2e67e312fae0133ac982edaae790537b9dde000b92a4f99bba500a5318860ec8fe8b2ba588bf16f09e9b1c465335cda700722cb5b9373d61656
7
- data.tar.gz: 60e517386590fe578d49fb12d08e084f9020fedbec3034cafa75b43a4d25189d783bb08de7f9461fc65d49c90e6a1071561a6440ed6e7e5d415f5186ab2c2ea4
6
+ metadata.gz: 9ef78affe56fbe01050f3ef209f7105b5c528406a76be5fc3810fca0bf50ebaf17aa7c57bcade9098035ee6077c7e9d8d95e92d6790e5a10e3bc8cdadd7b9163
7
+ data.tar.gz: 438cd3f955a8085f0393f1b233c4773000c25809112240bdec8ab067b6d17f3290735bff2741a6ea2856a620f2974115a28b8a6699c59c6a6c6b231e0922a486
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rack-proxy (0.5.17)
4
+ rack-proxy (0.5.18)
5
5
  rack
6
6
 
7
7
  GEM
@@ -7,6 +7,7 @@ module Rack
7
7
  attr_accessor :use_ssl
8
8
  attr_accessor :verify_mode
9
9
  attr_accessor :read_timeout
10
+ attr_accessor :ssl_version
10
11
 
11
12
  def initialize(request, host, port = nil)
12
13
  @request, @host, @port = request, host, port
@@ -65,6 +66,7 @@ module Rack
65
66
  http.use_ssl = self.use_ssl
66
67
  http.verify_mode = self.verify_mode
67
68
  http.read_timeout = self.read_timeout
69
+ http.ssl_version = self.ssl_version if self.use_ssl
68
70
  http.start
69
71
  end
70
72
  end
@@ -5,12 +5,12 @@ module Rack
5
5
 
6
6
  # Subclass and bring your own #rewrite_request and #rewrite_response
7
7
  class Proxy
8
- VERSION = "0.5.17"
8
+ VERSION = "0.5.18"
9
9
 
10
10
  class << self
11
11
  def extract_http_request_headers(env)
12
12
  headers = env.reject do |k, v|
13
- !(/^HTTP_[A-Z_]+$/ === k) || v.nil?
13
+ !(/^HTTP_[A-Z0-9_]+$/ === k) || v.nil?
14
14
  end.map do |k, v|
15
15
  [reconstruct_header_name(k), v]
16
16
  end.inject(Utils::HeaderHash.new) do |hash, k_v|
@@ -44,6 +44,7 @@ module Rack
44
44
  @ssl_verify_none = opts.fetch(:ssl_verify_none, false)
45
45
  @backend = URI(opts[:backend]) if opts[:backend]
46
46
  @read_timeout = opts.fetch(:read_timeout, 60)
47
+ @ssl_version = opts[:ssl_version] if opts[:ssl_version]
47
48
  end
48
49
 
49
50
  def call(env)
@@ -97,11 +98,15 @@ module Rack
97
98
  target_response.use_ssl = use_ssl
98
99
  target_response.read_timeout = read_timeout
99
100
  target_response.verify_mode = OpenSSL::SSL::VERIFY_NONE if use_ssl && ssl_verify_none
101
+ target_response.ssl_version = @ssl_version if @ssl_version
100
102
  else
101
- start_opts = use_ssl ? {:use_ssl => use_ssl} : {}
102
- start_opts[:verify_mode] = OpenSSL::SSL::VERIFY_NONE if use_ssl && ssl_verify_none
103
- start_opts[:read_timeout] = read_timeout
104
- target_response = Net::HTTP.start(backend.host, backend.port, start_opts) do |http|
103
+ http = Net::HTTP.new(backend.host, backend.port)
104
+ http.use_ssl = use_ssl if use_ssl
105
+ http.read_timeout = read_timeout
106
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE if use_ssl && ssl_verify_none
107
+ http.ssl_version = @ssl_version if @ssl_version
108
+
109
+ target_response = http.start do
105
110
  http.request(target_request)
106
111
  end
107
112
  end
@@ -33,7 +33,6 @@ class HttpStreamingResponseTest < Test::Unit::TestCase
33
33
  assert chunk.is_a?(String)
34
34
  end
35
35
 
36
-
37
36
  end
38
37
 
39
38
  def test_to_s
@@ -6,11 +6,11 @@ class NetHttpHackedTest < Test::Unit::TestCase
6
6
  def test_net_http_hacked
7
7
  req = Net::HTTP::Get.new("/")
8
8
  http = Net::HTTP.start("www.iana.org", "80")
9
-
9
+
10
10
  # Response code
11
11
  res = http.begin_request_hacked(req)
12
12
  assert res.code == "200"
13
-
13
+
14
14
  # Headers
15
15
  headers = {}
16
16
  res.each_header { |k, v| headers[k] = v }
@@ -18,18 +18,18 @@ class NetHttpHackedTest < Test::Unit::TestCase
18
18
  assert headers.size > 0
19
19
  assert headers["content-type"] == "text/html; charset=UTF-8"
20
20
  assert !headers["date"].nil?
21
-
21
+
22
22
  # Body
23
23
  chunks = []
24
24
  res.read_body do |chunk|
25
25
  chunks << chunk
26
26
  end
27
-
27
+
28
28
  assert chunks.size > 0
29
29
  chunks.each do |chunk|
30
30
  assert chunk.is_a?(String)
31
31
  end
32
-
32
+
33
33
  http.end_request_hacked
34
34
  end
35
35
 
@@ -42,6 +42,13 @@ class RackProxyTest < Test::Unit::TestCase
42
42
  assert_match(/(itunes|iphone|ipod|mac|ipad)/, last_response.body)
43
43
  end
44
44
 
45
+ def test_https_streaming_tls
46
+ app(:ssl_version => :TLSv1).host = 'www.apple.com'
47
+ get 'https://example.com'
48
+ assert last_response.ok?
49
+ assert_match(/(itunes|iphone|ipod|mac|ipad)/, last_response.body)
50
+ end
51
+
45
52
  def test_https_full_request
46
53
  app(:streaming => false).host = 'www.apple.com'
47
54
  get 'https://example.com'
@@ -49,6 +56,13 @@ class RackProxyTest < Test::Unit::TestCase
49
56
  assert_match(/(itunes|iphone|ipod|mac|ipad)/, last_response.body)
50
57
  end
51
58
 
59
+ def test_https_full_request_tls
60
+ app({:streaming => false, :ssl_version => :TLSv1}).host = 'www.apple.com'
61
+ get 'https://example.com'
62
+ assert last_response.ok?
63
+ assert_match(/(itunes|iphone|ipod|mac|ipad)/, last_response.body)
64
+ end
65
+
52
66
  def test_normalize_headers
53
67
  proxy_class = Rack::Proxy
54
68
  headers = { 'header_array' => ['first_entry'], 'header_non_array' => :entry }
@@ -74,11 +88,13 @@ class RackProxyTest < Test::Unit::TestCase
74
88
  env = {
75
89
  'NOT-HTTP-HEADER' => 'test-value',
76
90
  'HTTP_ACCEPT' => 'text/html',
77
- 'HTTP_CONNECTION' => nil
91
+ 'HTTP_CONNECTION' => nil,
92
+ 'HTTP_CONTENT_MD5' => 'deadbeef'
78
93
  }
79
94
 
80
95
  headers = proxy_class.extract_http_request_headers(env)
81
96
  assert headers.key?('ACCEPT')
97
+ assert headers.key?('CONTENT-MD5')
82
98
  assert !headers.key?('CONNECTION')
83
99
  assert !headers.key?('NOT-HTTP-HEADER')
84
100
  end
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-proxy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.17
4
+ version: 0.5.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jacek Becela
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-27 00:00:00.000000000 Z
11
+ date: 2016-05-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rack-test
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  description: A Rack app that provides request/response rewriting proxy capabilities
@@ -46,7 +46,7 @@ executables: []
46
46
  extensions: []
47
47
  extra_rdoc_files: []
48
48
  files:
49
- - .gitignore
49
+ - ".gitignore"
50
50
  - Gemfile
51
51
  - Gemfile.lock
52
52
  - LICENSE
@@ -70,17 +70,17 @@ require_paths:
70
70
  - lib
71
71
  required_ruby_version: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  required_rubygems_version: !ruby/object:Gem::Requirement
77
77
  requirements:
78
- - - '>='
78
+ - - ">="
79
79
  - !ruby/object:Gem::Version
80
80
  version: '0'
81
81
  requirements: []
82
82
  rubyforge_project: rack-proxy
83
- rubygems_version: 2.0.3
83
+ rubygems_version: 2.5.1
84
84
  signing_key:
85
85
  specification_version: 4
86
86
  summary: A request/response rewriting HTTP proxy. A Rack app.