prerender_rails 0.1.4 → 0.1.5

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: 6169bab7bdff0a4a0a23fa01c787bf38509ab2a9
4
- data.tar.gz: 51fd5886bfc1969f8f762a18319d560555665ae1
3
+ metadata.gz: 9f6ccf511a4930229738289e20a58cd4563699b9
4
+ data.tar.gz: bd43962bf1bb2388b622903626cae2d7f0f6c86a
5
5
  SHA512:
6
- metadata.gz: 2d574c159a63aad090cf6fe59ec7ee76c8ce20e5c207b4ce90115daca0949dd4ced1006d7544a04e260676c75a780d1b0a11a75f6d5c1f845e1b9c57dcc61748
7
- data.tar.gz: d54dcd31268906d7676cfe10015b559388f905895103ee7e0c460f1b5a073e722f61d6af0d64e1e5141c180e53c20bf1e225c50b6c931b92daedb245cdd75ae9
6
+ metadata.gz: 78c2a53a69a90f6b39b3cf72b456d74880376af05e73503c82603c8988ee5a79116d0264a555e302c05c1b0c91177ffd9876dc0ebbd594e93b8f42a52a3f06d0
7
+ data.tar.gz: e23f7ab089d525a29f7d6c902722147722c6fabad1cf4d8caf90bc81aac6985012aa0b085402a5b433919b9fba5aeaf976db9b9484ae1eb8a5735297670cd0ad
@@ -110,7 +110,9 @@ module Rack
110
110
 
111
111
  def get_prerendered_page_response(env)
112
112
  begin
113
- Net::HTTP.get_response(URI.parse(build_api_url(env)))
113
+ url = URI.parse(build_api_url(env))
114
+ req = Net::HTTP::Get.new(url.request_uri, { 'User-Agent' => env['HTTP_USER_AGENT'] })
115
+ response = Net::HTTP.start(url.host, url.port) { |http| http.request(req) }
114
116
  rescue
115
117
  nil
116
118
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "prerender_rails"
5
- spec.version = "0.1.4"
5
+ spec.version = "0.1.5"
6
6
  spec.authors = ["Todd Hooper"]
7
7
  spec.email = ["todd@collectiveip.com"]
8
8
  spec.description = %q{Rails middleware to prerender your javascript heavy pages on the fly by a phantomjs service}
@@ -15,7 +15,7 @@ describe Rack::Prerender do
15
15
 
16
16
  it "should return a prerendered response for a crawler with the returned status code" do
17
17
  request = Rack::MockRequest.env_for "/", "HTTP_USER_AGENT" => bot
18
- stub_request(:get, @prerender.build_api_url(request)).to_return(:body => "<html></html>", :status => 201)
18
+ stub_request(:get, @prerender.build_api_url(request)).with(:headers => { 'User-Agent' => bot }).to_return(:body => "<html></html>", :status => 201)
19
19
  response = Rack::Prerender.new(@app).call(request)
20
20
 
21
21
  assert_equal response[2].body, ["<html></html>"]
@@ -24,7 +24,7 @@ describe Rack::Prerender do
24
24
 
25
25
  it "should return a prerendered reponse if user is a bot by checking for _escaped_fragment_" do
26
26
  request = Rack::MockRequest.env_for "/path?_escaped_fragment_=", "HTTP_USER_AGENT" => user
27
- stub_request(:get, @prerender.build_api_url(request)).to_return(:body => "<html></html>")
27
+ stub_request(:get, @prerender.build_api_url(request)).with(:headers => { 'User-Agent' => user }).to_return(:body => "<html></html>")
28
28
  response = Rack::Prerender.new(@app).call(request)
29
29
 
30
30
  assert_equal response[2].body, ["<html></html>"]
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.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Todd Hooper
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-27 00:00:00.000000000 Z
11
+ date: 2013-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack