falcon 0.14.3 → 0.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/falcon.gemspec +1 -1
- data/lib/falcon/proxy.rb +32 -1
- data/lib/falcon/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab0c608a95c35a69f5b5d4e1cb058d77537cc13a652261e4efd27c2270e5f09e
|
4
|
+
data.tar.gz: 517ca951cd32e0cbfc9c39a9490835be04cfc0ebac6023c07e9d6f9612958ba2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3e5e0622585b3caf56a2a8dd0ea2eb23433c80f4071e7d0c06f3de55d5ccfe615ef5c30a23c81d04a81ee71269b87fcca6b040b9388494efe6584bca8e76380
|
7
|
+
data.tar.gz: 696f421a3f74d39ced161f2596f8b630b2d58a441e1a6dc1b577c18fd2dda8340fcccdccce668f150641ec995b65c3d00bf9e6612107a8ee6a1e09fa2fd607e4
|
data/falcon.gemspec
CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.require_paths = ["lib"]
|
18
18
|
|
19
19
|
spec.add_dependency("async-io", "~> 1.9")
|
20
|
-
spec.add_dependency("async-http", "~> 0.
|
20
|
+
spec.add_dependency("async-http", "~> 0.24.0")
|
21
21
|
spec.add_dependency("async-container", "~> 0.5.0")
|
22
22
|
|
23
23
|
spec.add_dependency("rack", ">= 1.0")
|
data/lib/falcon/proxy.rb
CHANGED
@@ -31,6 +31,19 @@ module Falcon
|
|
31
31
|
end
|
32
32
|
|
33
33
|
class Proxy < Async::HTTP::Middleware
|
34
|
+
X_FORWARDED_FOR = 'x-forwarded-for'.freeze
|
35
|
+
VIA = 'via'.freeze
|
36
|
+
CONNECTION = Async::HTTP::Protocol::HTTP11::CONNECTION
|
37
|
+
|
38
|
+
HOP_HEADERS = [
|
39
|
+
'connection',
|
40
|
+
'keep-alive',
|
41
|
+
'public',
|
42
|
+
'proxy-authenticate',
|
43
|
+
'transfer-encoding',
|
44
|
+
'upgrade',
|
45
|
+
]
|
46
|
+
|
34
47
|
def initialize(app, hosts)
|
35
48
|
super(app)
|
36
49
|
|
@@ -61,16 +74,34 @@ module Falcon
|
|
61
74
|
end
|
62
75
|
end
|
63
76
|
|
64
|
-
def
|
77
|
+
def prepare_headers(headers)
|
78
|
+
if connection = headers[CONNECTION]
|
79
|
+
headers.slice!(connection)
|
80
|
+
end
|
81
|
+
|
82
|
+
headers.slice!(HOP_HEADERS)
|
83
|
+
end
|
84
|
+
|
85
|
+
def call(request, peer: nil, **options)
|
65
86
|
if endpoint = lookup(request)
|
66
87
|
@count += 1
|
67
88
|
|
89
|
+
if peer and address = peer.remote_address and address.ip?
|
90
|
+
request.headers.add(X_FORWARDED_FOR, address.ip_address)
|
91
|
+
end
|
92
|
+
|
93
|
+
request.headers.add(VIA, "#{request.version} #{self.class}")
|
94
|
+
|
68
95
|
client = connect(endpoint)
|
69
96
|
|
97
|
+
prepare_headers(request.headers)
|
70
98
|
client.call(request)
|
71
99
|
else
|
72
100
|
super
|
73
101
|
end
|
102
|
+
rescue
|
103
|
+
Async.logger.error(self) {$!}
|
104
|
+
return Async::HTTP::Response[502, {'content-type' => 'text/plain'}, ["#{$!.inspect}: #{$!.backtrace.join("\n")}"]]
|
74
105
|
end
|
75
106
|
end
|
76
107
|
end
|
data/lib/falcon/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: falcon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-05-
|
11
|
+
date: 2018-05-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: async-io
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: 0.24.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.
|
40
|
+
version: 0.24.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: async-container
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|