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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a97826b0932a0dd0383188792fc77d18cbc8e218
4
- data.tar.gz: ef4d2a1f753ddc01c0f61ee16a6ebae5c6fef061
3
+ metadata.gz: 657b30783f55c76a446e535831f6ae903b2c31a4
4
+ data.tar.gz: 184b70e7b4d90610c89ea884a578f694c7192478
5
5
  SHA512:
6
- metadata.gz: b043877992ad2aa6be09535cbcaf219a36b6aef092630be7d6b466a69cff00599a89fa4c0029633a3287f483d260ea4b2287f3f9f528f5a2c948289dc09741d8
7
- data.tar.gz: 8bf6aeee6d694677d4a0c9c20e1e62098af6be899e49e32803e4d73c1bfada85d6c97e376668d5eb05591099bc444a684fe2e9e768ac0eecf41a66020eb19804
6
+ metadata.gz: 8818332cfe38000f7f2b9fd81f35545cbed654696130fa3e1425960018bf5092be31dbe7e6a938960fbe729e1ebb00bab6e914f959019c82fa84e171cdc3f5d9
7
+ data.tar.gz: 9d8e5ccdb5f63dd8e7042ffd5971b8973b67fdb3a9e87384443cddcc33f2323ba0e0466ae0256c7df1c760614bea7bac71ec0d3cd9fd12c0b802b38471feffa3
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  require 'json'
3
3
  require 'jekyll'
4
4
  require 'rack'
5
- require 'rack/streaming_proxy'
5
+ require 'rack/proxy'
6
6
  require 'restclient'
7
7
 
8
8
  module Bowtie
@@ -57,7 +57,7 @@ module Bowtie
57
57
  index: 'index.html'
58
58
 
59
59
  # Backend API proxy through BowTie
60
- run Bowtie::Middleware::Proxy.new(nil)
60
+ run Bowtie::Middleware::Proxy.new
61
61
  end
62
62
  end
63
63
  end
@@ -1,16 +1,16 @@
1
1
  module Bowtie::Middleware
2
2
  class Proxy
3
3
  def initialize(*args)
4
- @platform = Platform.new(*args)
5
- @backend = Backend.new(*args)
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::StreamingProxy::Proxy
23
- def destination_uri(rack_request)
24
- rack_request.env[:proxy_location]
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::StreamingProxy::Proxy
29
- def destination_uri(rack_request)
30
- fqdn = Bowtie::Settings['client']['fqdn']
31
- base_url = "https://#{fqdn}"
32
- path = rack_request.path
33
-
34
- rack_request.env[:proxy_addon_headers] = {
35
- 'X-Forwarded-Host' => rack_request.host_with_port,
36
- 'X-Forwarded-Port' => rack_request.port,
37
- 'X-Forwarded-Proto' => 'http',
38
- 'X-Forwarded-Scheme' => 'http',
39
- 'X-Bowtie-Client-Version' => Bowtie::VERSION
40
- }
41
-
42
- uri = URI.join(base_url, path)
43
- uri.query = rack_request.query_string
44
- uri.to_s
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
@@ -1,3 +1,3 @@
1
1
  module Bowtie
2
- VERSION = '1.0.16'
2
+ VERSION = '1.2.0'
3
3
  end
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.16
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-14 00:00:00.000000000 Z
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: bowtie-io-rack-streaming-proxy
42
+ name: rack-proxy
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '2.0'
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: '2.0'
54
+ version: 0.5.17
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rest-client
57
57
  requirement: !ruby/object:Gem::Requirement