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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0d3d10314d397ff73d14421024f662ee818be5ce
4
- data.tar.gz: ce5856ec13f3a36c7132fa24fbff7a56d2a9203c
3
+ metadata.gz: 3428e6ef27227f99c1dcf5d72a6a36ab5c1c3563
4
+ data.tar.gz: 29204ed05a07cf2372c3b7fd81d03647304372e0
5
5
  SHA512:
6
- metadata.gz: 407afac47e2f903fb5c379b2281a771d5ef00620b2c4dbef55a6a6048dc8af839cd02b6f623b43a9234f07ed6988bf64586b65549fe477af364404721cc45590
7
- data.tar.gz: 8845e00d5f435acd21bcf2702be29a2e49ed03723317bae6cdb16e2da77bfc0a5ea9ee7a9f92a51854898a83e67138e4a30250e0eea49e379956e31aad14f595
6
+ metadata.gz: d39750e97c1b8eab48ca445eb212d563838e22a40012daac9343f225bfebd882a2896282ea05df6c926343e8c9b5d274a7d2ec449de5cc4becc4c2440a6827fc
7
+ data.tar.gz: d2b51386bae91a75e07ead88fed9b21e8dade23032034da2cd9b420a6d5f5047b3fce3f8b49ff00a27ec19d391004261f46ed642bfd01334773561394bdb2368
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rack-proxy (0.5.0)
4
+ rack-proxy (0.5.2)
5
5
  rack
6
6
 
7
7
  GEM
@@ -10,9 +10,15 @@ module Rack
10
10
  @request, @host, @port = request, host, port
11
11
  end
12
12
 
13
- def status
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)
@@ -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.1"
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 a streaming response (the actual network communication is deferred, a.k.a. streamed)
56
+ # Create the response
56
57
  if @streaming
57
- if @backend
58
- target_response = HttpStreamingResponse.new(target_request, @backend.host, @backend.port)
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
- host = (@backend && @backend.host) || source_request.host
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
- triplet
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)
@@ -10,6 +10,7 @@ class HttpStreamingResponseTest < Test::Unit::TestCase
10
10
 
11
11
  def test_streaming
12
12
  # Response status
13
+ assert @response.code == 200
13
14
  assert @response.status == 200
14
15
 
15
16
  # Headers
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.1
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-08-22 00:00:00.000000000 Z
11
+ date: 2013-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack