bowtie-io 1.0.16 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bowtie.rb +1 -1
- data/lib/bowtie/commands/serve.rb +1 -1
- data/lib/bowtie/middleware/proxy.rb +45 -24
- data/lib/bowtie/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 657b30783f55c76a446e535831f6ae903b2c31a4
|
4
|
+
data.tar.gz: 184b70e7b4d90610c89ea884a578f694c7192478
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8818332cfe38000f7f2b9fd81f35545cbed654696130fa3e1425960018bf5092be31dbe7e6a938960fbe729e1ebb00bab6e914f959019c82fa84e171cdc3f5d9
|
7
|
+
data.tar.gz: 9d8e5ccdb5f63dd8e7042ffd5971b8973b67fdb3a9e87384443cddcc33f2323ba0e0466ae0256c7df1c760614bea7bac71ec0d3cd9fd12c0b802b38471feffa3
|
data/lib/bowtie.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
module Bowtie::Middleware
|
2
2
|
class Proxy
|
3
3
|
def initialize(*args)
|
4
|
-
@platform = Platform.new
|
5
|
-
@backend = Backend.new
|
4
|
+
@platform = Platform.new
|
5
|
+
@backend = Backend.new
|
6
6
|
end
|
7
7
|
|
8
8
|
def call(env)
|
9
9
|
status, headers, body = @platform.call(env)
|
10
10
|
|
11
11
|
if status.to_i == 305
|
12
|
-
env[:proxy_addon_headers] = JSON.load(headers['X-Bowtie-Client-Proxy-Headers'])
|
13
|
-
env[:proxy_location] = headers['Location']
|
12
|
+
env[:proxy_addon_headers] = JSON.load(headers['X-Bowtie-Client-Proxy-Headers'].first)
|
13
|
+
env[:proxy_location] = headers['Location'].first
|
14
14
|
@backend.call(env)
|
15
15
|
else
|
16
16
|
[status, headers, body]
|
@@ -19,29 +19,50 @@ module Bowtie::Middleware
|
|
19
19
|
end
|
20
20
|
|
21
21
|
private
|
22
|
-
class Backend < Rack::
|
23
|
-
def
|
24
|
-
|
22
|
+
class Backend < Rack::Proxy
|
23
|
+
def self.extract_http_request_headers(env)
|
24
|
+
addon_headers = env[:proxy_addon_headers].inject({}) { |h,v| h[v[0]] = v[1].to_s; h }
|
25
|
+
super(env).merge!(addon_headers)
|
26
|
+
end
|
27
|
+
|
28
|
+
protected
|
29
|
+
def perform_request(env)
|
30
|
+
@backend = URI(env[:proxy_location])
|
31
|
+
|
32
|
+
env['REQUEST_URI'] = @backend.request_uri
|
33
|
+
env['HTTP_HOST'] = @backend.host
|
34
|
+
|
35
|
+
super(env)
|
25
36
|
end
|
26
37
|
end
|
27
38
|
|
28
|
-
class Platform < Rack::
|
29
|
-
def
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
39
|
+
class Platform < Rack::Proxy
|
40
|
+
def rewrite_env(env)
|
41
|
+
rack_request = Rack::Request.new(env)
|
42
|
+
|
43
|
+
env['HTTPS'] = 'on'
|
44
|
+
env['SERVER_PORT'] = 443
|
45
|
+
env['HTTP_HOST'] = Bowtie::Settings['client']['fqdn']
|
46
|
+
|
47
|
+
env['HTTP_X_FORWARDED_HOST'] = rack_request.host_with_port
|
48
|
+
env['HTTP_X_FORWARDED_PROTO'] = rack_request.port.to_s
|
49
|
+
env['HTTP_X_FORWARDED_SCHEME'] = 'http'
|
50
|
+
env['HTTP_X_BOWTIE_CLIENT_VERSION'] = Bowtie::VERSION
|
51
|
+
|
52
|
+
env
|
53
|
+
end
|
54
|
+
|
55
|
+
def rewrite_response(triplet)
|
56
|
+
status, headers, body = triplet
|
57
|
+
|
58
|
+
headers.delete('Transfer-Encoding')
|
59
|
+
|
60
|
+
[status, headers, body]
|
61
|
+
end
|
62
|
+
|
63
|
+
protected
|
64
|
+
def perform_request(env)
|
65
|
+
super(env)
|
45
66
|
end
|
46
67
|
end
|
47
68
|
end
|
data/lib/bowtie/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bowtie-io
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Kassemi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -39,19 +39,19 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.6'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: rack-proxy
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 0.5.17
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 0.5.17
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rest-client
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|