onebox 1.8.10 → 1.8.11

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: 456aaa9602502159cf7927cf63c8f12dac02fcdd
4
- data.tar.gz: bd0a13a8f4716ece3fbe7b4eae08eb56cec974d4
3
+ metadata.gz: b9fdd8decf0ce95f8a5c44381780bbc8d66e8c50
4
+ data.tar.gz: 8147a14fb6fd5990ace1e5cf2bcefa928a1e0ba9
5
5
  SHA512:
6
- metadata.gz: 2f249d787803f2182a17365d608be8f9806fddc299cd9a943993610c745ccc26fad939a679ae4a2af5591bb5c931c1a86c30e57c2344677e9c89fe5582724f2e
7
- data.tar.gz: 29f295edadf7c3945dcb0d2f848e3be6b001d036be10db49028573d37a11a3600eba47bb67885bff69f661de6ac232358f715ef9e9baa9a8a800608dbd5c6e20
6
+ metadata.gz: b0c8feea7c6a688a416f524d33d981377b5307e02aeb58e110679c239fb1b73a4c4fc5bc043eb6cda31e309a78065ee087194d483afa3c1c249c22017a03e643
7
+ data.tar.gz: 6f17186c5a4a3ae9dce8b4866b3c87d4c94d5c65a829b28ade3f4aa76d464f572ca05fcc45da173516f0b4abf7376dd53873994ff06307bfa8e01b4f3c4b77e8
@@ -50,7 +50,14 @@ module Onebox
50
50
  protected
51
51
 
52
52
  def html_doc
53
- @html_doc ||= Nokogiri::HTML((Onebox::Helpers.fetch_response(url) rescue nil))
53
+ return @html_doc if @html_doc
54
+
55
+ headers = nil
56
+ headers = { 'Cookie' => options[:cookie] } if options[:cookie]
57
+
58
+ response = (Onebox::Helpers.fetch_response(url, nil, nil, headers) rescue nil)
59
+
60
+ @html_doc = Nokogiri::HTML(response)
54
61
  end
55
62
 
56
63
  def get_oembed
@@ -39,8 +39,9 @@ module Onebox
39
39
  og
40
40
  end
41
41
 
42
- def self.fetch_response(location, limit=5, domain=nil, headers=nil)
42
+ def self.fetch_response(location, limit=nil, domain=nil, headers=nil)
43
43
 
44
+ limit ||= 5
44
45
  limit = Onebox.options.redirect_limit if limit > Onebox.options.redirect_limit
45
46
 
46
47
  raise Net::HTTPError.new('HTTP redirect too deep', location) if limit == 0
@@ -70,7 +71,7 @@ module Onebox
70
71
  http.request(request) do |response|
71
72
 
72
73
  if cookie = response.get_fields('set-cookie')
73
- header = { 'cookie' => cookie.join }
74
+ header = { 'Cookie' => cookie.join }
74
75
  end
75
76
 
76
77
  header = nil unless header.is_a? Hash
@@ -66,7 +66,11 @@ module Onebox
66
66
 
67
67
  def engine
68
68
  return nil unless @engine_class
69
- @engine ||= @engine_class.new(@url, cache)
69
+ return @engine if @engine
70
+
71
+ @engine = @engine_class.new(@url, cache)
72
+ @engine.options = @options
73
+ @engine
70
74
  end
71
75
 
72
76
  class InvalidURI < StandardError; end
@@ -1,3 +1,3 @@
1
1
  module Onebox
2
- VERSION = "1.8.10"
2
+ VERSION = "1.8.11"
3
3
  end
@@ -83,6 +83,20 @@ describe Onebox::Engine::WhitelistedGenericOnebox do
83
83
  end
84
84
  end
85
85
 
86
+ describe "cookie support" do
87
+ let(:url) { "http://cookie-test.com" }
88
+ before do
89
+ fake(url, response('dailymail'))
90
+ end
91
+
92
+ it "sends the cookie with the request" do
93
+ onebox = described_class.new(url)
94
+ onebox.options = { cookie: "evil=trout" }
95
+ expect(onebox.to_html).not_to be_empty
96
+ expect(FakeWeb.last_request['Cookie']).to eq('evil=trout')
97
+ end
98
+ end
99
+
86
100
  describe 'to_html' do
87
101
  after(:each) do
88
102
  Onebox.options = Onebox::DEFAULTS
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: onebox
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.10
4
+ version: 1.8.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joanna Zeta
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2017-06-02 00:00:00.000000000 Z
13
+ date: 2017-06-06 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: multi_json