rack-proxy 0.7.4 → 0.7.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +2 -2
- data/lib/rack/http_streaming_response.rb +1 -3
- data/lib/rack/proxy.rb +13 -7
- data/lib/rack_proxy_examples/example_service_proxy.rb +1 -1
- data/test/http_streaming_response_test.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb78b8ebb5f71066481f1cbbf87fe0709b9a89d7da3da1ed86d5a095a4cb8ebb
|
4
|
+
data.tar.gz: aeeff912be2bf0bc5b75cae9f94192c2feae70742d734a2bd7fbf247cfd7c091
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 557cf33c379e4e2847196fd77c5bdc25c802fcc0ac112cd56780459145927b664dad1d86ccaf9d2f65eadf3ce1faedc2c26e8bdc84ac79ef8eb40f98f57c604e
|
7
|
+
data.tar.gz: edc8229c7b4a936d9a4f9f1717cd0f07144597b54fae6a89f5d528692436cb6005ae01778a603f20748518ba2b034c161de576d917abb8789632e0040378916d
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -6,7 +6,7 @@ Installation
|
|
6
6
|
Add the following to your `Gemfile`:
|
7
7
|
|
8
8
|
```
|
9
|
-
gem 'rack-proxy', '~> 0.7.
|
9
|
+
gem 'rack-proxy', '~> 0.7.5'
|
10
10
|
```
|
11
11
|
|
12
12
|
Or install:
|
@@ -136,7 +136,7 @@ Test with `require 'rack_proxy_examples/example_service_proxy'`
|
|
136
136
|
# 1. rails new test_app
|
137
137
|
# 2. cd test_app
|
138
138
|
# 3. install Rack-Proxy in `Gemfile`
|
139
|
-
# a. `gem 'rack-proxy', '~> 0.7.
|
139
|
+
# a. `gem 'rack-proxy', '~> 0.7.5'`
|
140
140
|
# 4. install gem: `bundle install`
|
141
141
|
# 5. create `config/initializers/proxy.rb` adding this line `require 'rack_proxy_examples/example_service_proxy'`
|
142
142
|
# 6. run: `SERVICE_URL=http://guides.rubyonrails.org rails server`
|
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.7.
|
8
|
+
VERSION = "0.7.5".freeze
|
9
9
|
|
10
10
|
HOP_BY_HOP_HEADERS = {
|
11
11
|
'connection' => true,
|
@@ -24,11 +24,7 @@ module Rack
|
|
24
24
|
!(/^HTTP_[A-Z0-9_\.]+$/ === k) || v.nil?
|
25
25
|
end.map do |k, v|
|
26
26
|
[reconstruct_header_name(k), v]
|
27
|
-
end.
|
28
|
-
k, v = k_v
|
29
|
-
hash[k] = v
|
30
|
-
hash
|
31
|
-
end
|
27
|
+
end.then { |pairs| build_header_hash(pairs) }
|
32
28
|
|
33
29
|
x_forwarded_for = (headers['X-Forwarded-For'].to_s.split(/, +/) << env['REMOTE_ADDR']).join(', ')
|
34
30
|
|
@@ -39,7 +35,17 @@ module Rack
|
|
39
35
|
mapped = headers.map do |k, v|
|
40
36
|
[titleize(k), if v.is_a? Array then v.join("\n") else v end]
|
41
37
|
end
|
42
|
-
|
38
|
+
build_header_hash Hash[mapped]
|
39
|
+
end
|
40
|
+
|
41
|
+
def build_header_hash(pairs)
|
42
|
+
if Rack.const_defined?(:Headers)
|
43
|
+
# Rack::Headers is only available from Rack 3 onward
|
44
|
+
Headers.new.tap { |headers| pairs.each { |k, v| headers[k] = v } }
|
45
|
+
else
|
46
|
+
# Rack::Utils::HeaderHash is deprecated from Rack 3 onward and is to be removed in 3.1
|
47
|
+
Utils::HeaderHash.new(pairs)
|
48
|
+
end
|
43
49
|
end
|
44
50
|
|
45
51
|
protected
|
@@ -5,7 +5,7 @@
|
|
5
5
|
# 1. rails new test_app
|
6
6
|
# 2. cd test_app
|
7
7
|
# 3. install Rack-Proxy in `Gemfile`
|
8
|
-
# a. `gem 'rack-proxy', '~> 0.7.
|
8
|
+
# a. `gem 'rack-proxy', '~> 0.7.5'`
|
9
9
|
# 4. install gem: `bundle install`
|
10
10
|
# 5. create `config/initializers/proxy.rb` adding this line `require 'rack_proxy_examples/example_service_proxy'`
|
11
11
|
# 6. run: `SERVICE_URL=http://guides.rubyonrails.org rails server`
|
@@ -4,7 +4,7 @@ require "rack/http_streaming_response"
|
|
4
4
|
class HttpStreamingResponseTest < Test::Unit::TestCase
|
5
5
|
|
6
6
|
def setup
|
7
|
-
host, req = "
|
7
|
+
host, req = "example.com", Net::HTTP::Get.new("/")
|
8
8
|
@response = Rack::HttpStreamingResponse.new(req, host, 443)
|
9
9
|
@response.use_ssl = true
|
10
10
|
end
|
@@ -37,7 +37,7 @@ class HttpStreamingResponseTest < Test::Unit::TestCase
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def test_to_s
|
40
|
-
assert_equal @response.headers["Content-Length"].first.to_i, @response.body.to_s.
|
40
|
+
assert_equal @response.headers["Content-Length"].first.to_i, @response.body.to_s.bytesize
|
41
41
|
end
|
42
42
|
|
43
43
|
def test_to_s_called_twice
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-proxy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jacek Becela
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|