rack-proxy 0.5.1 → 0.5.2
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/lib/rack/http_streaming_response.rb +7 -5
- data/lib/rack/proxy.rb +9 -20
- data/test/http_streaming_response_test.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3428e6ef27227f99c1dcf5d72a6a36ab5c1c3563
|
4
|
+
data.tar.gz: 29204ed05a07cf2372c3b7fd81d03647304372e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d39750e97c1b8eab48ca445eb212d563838e22a40012daac9343f225bfebd882a2896282ea05df6c926343e8c9b5d274a7d2ec449de5cc4becc4c2440a6827fc
|
7
|
+
data.tar.gz: d2b51386bae91a75e07ead88fed9b21e8dade23032034da2cd9b420a6d5f5047b3fce3f8b49ff00a27ec19d391004261f46ed642bfd01334773561394bdb2368
|
data/Gemfile.lock
CHANGED
@@ -10,9 +10,15 @@ module Rack
|
|
10
10
|
@request, @host, @port = request, host, port
|
11
11
|
end
|
12
12
|
|
13
|
-
def
|
13
|
+
def body
|
14
|
+
self
|
15
|
+
end
|
16
|
+
|
17
|
+
def code
|
14
18
|
response.code.to_i
|
15
19
|
end
|
20
|
+
# #status is deprecated
|
21
|
+
alias_method :status, :code
|
16
22
|
|
17
23
|
def headers
|
18
24
|
h = Utils::HeaderHash.new
|
@@ -24,10 +30,6 @@ module Rack
|
|
24
30
|
h
|
25
31
|
end
|
26
32
|
|
27
|
-
def body
|
28
|
-
self
|
29
|
-
end
|
30
|
-
|
31
33
|
# Can be called only once!
|
32
34
|
def each(&block)
|
33
35
|
response.read_body(&block)
|
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.5.
|
8
|
+
VERSION = "0.5.2"
|
9
9
|
|
10
10
|
# @option opts [String, URI::HTTP] :backend Backend host to proxy requests to
|
11
11
|
def initialize(opts={})
|
@@ -51,32 +51,21 @@ module Rack
|
|
51
51
|
target_request.content_type = source_request.content_type if source_request.content_type
|
52
52
|
end
|
53
53
|
|
54
|
+
backend = @backend || source_request
|
54
55
|
|
55
|
-
# Create
|
56
|
+
# Create the response
|
56
57
|
if @streaming
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
target_response.use_ssl = "https" == @backend.scheme
|
61
|
-
else
|
62
|
-
target_response = HttpStreamingResponse.new(target_request, source_request.host, source_request.port)
|
63
|
-
|
64
|
-
target_response.use_ssl = "https" == source_request.scheme
|
65
|
-
end
|
66
|
-
|
67
|
-
triplet = [target_response.status, target_response.headers, target_response.body]
|
58
|
+
# streaming response (the actual network communication is deferred, a.k.a. streamed)
|
59
|
+
target_response = HttpStreamingResponse.new(target_request, backend.host, backend.port)
|
60
|
+
target_response.use_ssl = backend.scheme == "https"
|
68
61
|
else
|
69
|
-
|
70
|
-
port = (@backend && @backend.port) || source_request.port
|
71
|
-
target_response = Net::HTTP.start(host, port) do |http|
|
62
|
+
target_response = Net::HTTP.start(backend.host, backend.port) do |http|
|
72
63
|
http.request(target_request)
|
73
64
|
end
|
74
|
-
|
75
|
-
headers = (target_response.respond_to?(:headers) && target_response.headers) || {}
|
76
|
-
triplet = [target_response.code, headers, target_response.body]
|
77
65
|
end
|
78
66
|
|
79
|
-
|
67
|
+
headers = (target_response.respond_to?(:headers) && target_response.headers) || {}
|
68
|
+
[target_response.code, headers, target_response.body]
|
80
69
|
end
|
81
70
|
|
82
71
|
def extract_http_request_headers(env)
|
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.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jacek Becela
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-09-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|