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 +4 -4
- data/lib/roda/proxy/version.rb +1 -1
- data/lib/roda/proxy.rb +12 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98127852a5b1deb4d65c1c71c8ec9e048caf2ce22910663dd5c6ee85b6722d36
|
4
|
+
data.tar.gz: 0a1dd3d440b7473bc1f53122e53c6fb8f0adb56e6917908f082a588b2a36c43d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a04011921ea3bfe3570ebb322d1a4d81a9e106f2afb3f9cf4a0b98a4e424eceee219d3d95706582dc934d6415b4c934610c146759792f0819c77325d5611f960
|
7
|
+
data.tar.gz: 5fdce0b692c9d38b4e61659c53971811cb79e846fe704d259b52ae33670ae1e13248a909bd84679f7b1c00992bf69f1d03acfb469fa1508606a1d7aa1e06e286
|
data/lib/roda/proxy/version.rb
CHANGED
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
|
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
|
|