prerender_rails 0.1.16 → 0.1.17

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: a4e4b759f45b4c50892e48fab8a71a46888988e0
4
- data.tar.gz: bf5185b7e8c5bac65afc226b5536cc5593667e90
3
+ metadata.gz: 6edf330fb3dcade0261ecc6be8d4ac63a1efdf7f
4
+ data.tar.gz: 4360662571ae5ad3a2688cf441a55085308a53af
5
5
  SHA512:
6
- metadata.gz: d9e2e4e7347da9ae115139517f26b03d55a91b2f8e9b4a165b86d971cfedaf1d5eacb488e7597d3eb9f81cead484628afd780db73bbf325d8b7fe17b4aaab9e3
7
- data.tar.gz: 45f83dc9a8b8b0d85889132715c177b977bed42a5e4765bb3266803259b0e39315e323aef25b660c7b2c39a86aea297511115203774f869c85eba106f793ed73
6
+ metadata.gz: 62a64d33161fb5528d07a958ff14a8895a1994c75b8bed2b55a650f56572c655cdddfbaee1555898d74b497c24b1e98deb3ab19adfdcdba523292fe1c6cc8baf
7
+ data.tar.gz: 8f180ca36cfc36d31eb1620761eede3d6ca720ce69fba13d4743768675b3c8c79c51734ad2d7035a53e9932087306f585d8f1737eebf8b384a25d2a4ddde1075
@@ -150,6 +150,11 @@ module Rack
150
150
  new_env["HTTPS"] = false and new_env["rack.url_scheme"] = "http" and new_env["SERVER_PORT"] = 80 if (match && match[1] == "http")
151
151
  end
152
152
 
153
+ if env["X-FORWARDED-PROTO"]
154
+ new_env["HTTPS"] = true and new_env["rack.url_scheme"] = "https" and new_env["SERVER_PORT"] = 443 if env["X-FORWARDED-PROTO"] == "https"
155
+ new_env["HTTPS"] = false and new_env["rack.url_scheme"] = "http" and new_env["SERVER_PORT"] = 80 if env["X-FORWARDED-PROTO"] == "http"
156
+ end
157
+
153
158
  url = Rack::Request.new(new_env).url
154
159
  prerender_url = get_prerender_service_url()
155
160
  forward_slash = prerender_url[-1, 1] == '/' ? '' : '/'
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "prerender_rails"
5
- spec.version = "0.1.16"
5
+ spec.version = "0.1.17"
6
6
  spec.authors = ["Todd Hooper"]
7
7
  spec.email = ["todd@prerender.io"]
8
8
  spec.description = %q{Rails middleware to prerender your javascript heavy pages on the fly by a phantomjs service}
@@ -164,6 +164,14 @@ describe Rack::Prerender do
164
164
  ENV['PRERENDER_SERVICE_URL'] = nil
165
165
  assert_equal 'http://service.prerender.io/https://google.com/search?q=javascript', @prerender.build_api_url(request)
166
166
  end
167
+
168
+
169
+ # Check X-Forwarded-Proto because Heroku SSL Support terminates at the load balancer
170
+ it "should build the correct api url for the Heroku SSL Addon support" do
171
+ request = Rack::MockRequest.env_for "http://google.com/search?q=javascript", { 'X-FORWARDED-PROTO' => 'https'}
172
+ ENV['PRERENDER_SERVICE_URL'] = nil
173
+ assert_equal 'http://service.prerender.io/https://google.com/search?q=javascript', @prerender.build_api_url(request)
174
+ end
167
175
  end
168
176
 
169
177
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prerender_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.16
4
+ version: 0.1.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Todd Hooper
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-09 00:00:00.000000000 Z
11
+ date: 2014-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack