roda-proxy 1.0.0 → 1.0.1

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
  SHA256:
3
- metadata.gz: 1ae4d0a181837cb04d8af444ad3a7876bc1182c83a943bd615487da7e72c011f
4
- data.tar.gz: 1cd548656ada75429ccd2bb0d918a33d1854f008b1247bcd7fe24028cf20e815
3
+ metadata.gz: 98127852a5b1deb4d65c1c71c8ec9e048caf2ce22910663dd5c6ee85b6722d36
4
+ data.tar.gz: 0a1dd3d440b7473bc1f53122e53c6fb8f0adb56e6917908f082a588b2a36c43d
5
5
  SHA512:
6
- metadata.gz: 29cc8cef4d73ce1a109aee475a25da1adfe4d34eb027ba3928d70f84beb6369460adc602666872b1a2ad34cd1b61ad038cd46f34246e2e4b0a68d48fcc2c88a5
7
- data.tar.gz: 5009c2e0962d5c2a36b8301bacad8f75d3950855d34a79dd6df636f4f30293ed31d9952f7200ed9ed1bacd3da3bd3bde5466e292a5d57dabba25987e473077e2
6
+ metadata.gz: a04011921ea3bfe3570ebb322d1a4d81a9e106f2afb3f9cf4a0b98a4e424eceee219d3d95706582dc934d6415b4c934610c146759792f0819c77325d5611f960
7
+ data.tar.gz: 5fdce0b692c9d38b4e61659c53971811cb79e846fe704d259b52ae33670ae1e13248a909bd84679f7b1c00992bf69f1d03acfb469fa1508606a1d7aa1e06e286
@@ -2,6 +2,6 @@
2
2
 
3
3
  class Roda
4
4
  module Proxy
5
- VERSION = '1.0.0'
5
+ VERSION = '1.0.1'
6
6
  end
7
7
  end
data/lib/roda/proxy.rb CHANGED
@@ -54,9 +54,9 @@ class Roda
54
54
  shall_proxy = Random.rand(0.0..1.0) <= probability
55
55
 
56
56
  if shall_proxy && ( condition.respond_to?(:call) ? condition.call : condition )
57
- yield(self)
58
- else
59
57
  proxy
58
+ else
59
+ yield(self)
60
60
  end
61
61
  end
62
62
 
@@ -78,7 +78,11 @@ class Roda
78
78
  .split('_')
79
79
  .map(&:capitalize)
80
80
  .join('-')
81
- end.merge({ 'Host' => "#{_proxy_url.host}:#{_proxy_url.port}" })
81
+ end
82
+ .merge({
83
+ 'Host' => "#{_proxy_url.host}:#{_proxy_url.port}",
84
+ 'Via' => _via_header_string
85
+ })
82
86
  end
83
87
 
84
88
  def _proxy_request(req)
@@ -88,8 +92,13 @@ class Roda
88
92
  def _respond(proxied_response)
89
93
  response.status = proxied_response.status
90
94
  proxied_response.headers.each { |k, v| response[k] = v }
95
+ response['Via'] = _via_header_string
91
96
  response.write(proxied_response.body)
92
97
  end
98
+
99
+ def _via_header_string
100
+ "#{env['SERVER_PROTOCOL']} #{env['SERVER_NAME']}:#{env['SERVER_PORT']}"
101
+ end
93
102
  end
94
103
  end
95
104
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roda-proxy
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nigel Brookes-Thomas