maremma 2.4.3 → 2.4.4

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: 9123398e2a4985bd5cb51e8a5b4a2a32e9b49509
4
- data.tar.gz: bbc8b74f4ab96d54a2829200c2e39a894477ec21
3
+ metadata.gz: 18e454d0ed90bc2186a43110f85c09f029c37401
4
+ data.tar.gz: 4255d3ebb492bb1ab77788a7c8b3ecc0436478b1
5
5
  SHA512:
6
- metadata.gz: 85c44227f161562cbe438d419a29996ade8f5b9f666bb8d2067887f824f4140b064cce410d55bf80fb1d380a476335c05d23f3c691705da8efababc8d2a2d5cb
7
- data.tar.gz: b0bb553f9ec0fe8ceec0746531475a9557626c28c6eafef51d20b909335fedd6709475f12826457cf83cc966cca1cf03d8e3039aba3ac1a77c1016bf1da64744
6
+ metadata.gz: b5d1b13e6ff0fadb96cf23ae84fba0db57f77ab3f980bb3771e0caa31efe0dc35622ad5948808eacd91cd117920a44fc546adecbcc912d146504a692fcdff4dc
7
+ data.tar.gz: df0e246ca404b8ec7d3b604cba494a84110910d5c9750aa233874809e6ae0a7db40cac4386613d402ce4910bd2afc861b7948343a2c95f212f9e89e901fb9570
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- maremma (2.4.3)
4
+ maremma (2.4.4)
5
5
  activesupport (~> 4.2, >= 4.2.5)
6
6
  builder (~> 3.2, >= 3.2.2)
7
7
  excon (~> 0.45.0)
@@ -9,7 +9,7 @@ PATH
9
9
  faraday-encoding (~> 0.0.1)
10
10
  faraday_middleware (~> 0.10.0)
11
11
  multi_json (~> 1.11.2)
12
- nokogiri (~> 1.6.7)
12
+ nokogiri (~> 1.6, >= 1.6.8)
13
13
  oj (>= 2.18.3)
14
14
 
15
15
  GEM
@@ -39,13 +39,13 @@ GEM
39
39
  hashdiff (0.3.5)
40
40
  i18n (0.8.6)
41
41
  json (2.1.0)
42
- mini_portile2 (2.1.0)
42
+ mini_portile2 (2.2.0)
43
43
  minitest (5.10.3)
44
44
  multi_json (1.11.3)
45
45
  multipart-post (2.0.0)
46
- nokogiri (1.6.8.1)
47
- mini_portile2 (~> 2.1.0)
48
- oj (3.3.4)
46
+ nokogiri (1.8.0)
47
+ mini_portile2 (~> 2.2.0)
48
+ oj (3.3.5)
49
49
  public_suffix (2.0.5)
50
50
  rack (2.0.3)
51
51
  rack-test (0.7.0)
@@ -69,7 +69,7 @@ GEM
69
69
  docile (~> 1.1.0)
70
70
  json (>= 1.8, < 3)
71
71
  simplecov-html (~> 0.10.0)
72
- simplecov-html (0.10.1)
72
+ simplecov-html (0.10.2)
73
73
  thread_safe (0.3.6)
74
74
  tzinfo (1.2.3)
75
75
  thread_safe (~> 0.1)
data/lib/maremma.rb CHANGED
@@ -54,6 +54,25 @@ module Maremma
54
54
  rescue_faraday_error(error)
55
55
  end
56
56
 
57
+ def self.head(url, options={})
58
+ options[:headers] = set_request_headers(url, options)
59
+
60
+ conn = faraday_conn(options)
61
+
62
+ conn.options[:timeout] = options[:timeout] || DEFAULT_TIMEOUT
63
+
64
+ response = conn.head url, {}, options[:headers]
65
+
66
+ # return error if we are close to the rate limit, if supported in headers
67
+ if get_rate_limit_remaining(response.headers) < 10
68
+ return { 'errors' => [{ 'status' => 429, 'title' => "Too many requests" }] }
69
+ end
70
+
71
+ response.headers
72
+ rescue *NETWORKABLE_EXCEPTIONS => error
73
+ rescue_faraday_error(error)
74
+ end
75
+
57
76
  def self.faraday_conn(options = {})
58
77
  # make sure we have headers
59
78
  options[:headers] ||= {}
@@ -66,7 +85,7 @@ module Maremma
66
85
  c.headers['Content-type'] = options[:headers]['Content-type'] if options[:headers]['Content-type'].present?
67
86
  c.headers['Accept'] = options[:headers]['Accept']
68
87
  c.headers['User-Agent'] = options[:headers]['User-Agent']
69
- c.use FaradayMiddleware::FollowRedirects, limit: limit, cookie: :all
88
+ c.use FaradayMiddleware::FollowRedirects, limit: limit, cookie: :all if limit > 0
70
89
  c.request :multipart
71
90
  c.request :json if options[:headers]['Accept'] == 'application/json'
72
91
  c.use Faraday::Response::RaiseError
@@ -1,3 +1,3 @@
1
1
  module Maremma
2
- VERSION = "2.4.3"
2
+ VERSION = "2.4.4"
3
3
  end
data/maremma.gemspec CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |s|
23
23
  s.add_dependency 'faraday_middleware', '~> 0.10.0'
24
24
  s.add_dependency 'faraday-encoding', '~> 0.0.1'
25
25
  s.add_dependency 'excon', '~> 0.45.0'
26
- s.add_dependency 'nokogiri', '~> 1.6.7'
26
+ s.add_dependency 'nokogiri', '~> 1.6', '>= 1.6.8'
27
27
  s.add_dependency 'builder', '~> 3.2', '>= 3.2.2'
28
28
  s.add_dependency 'multi_json', '~> 1.11.2'
29
29
  s.add_dependency 'oj', '>= 2.18.3'
data/spec/maremma_spec.rb CHANGED
@@ -54,6 +54,15 @@ describe Maremma do
54
54
  end
55
55
  end
56
56
 
57
+ context "head" do
58
+ it "head html" do
59
+ stub = stub_request(:head, url).to_return(:status => 200, :headers => { "Content-Type" => "text/html" })
60
+ response = subject.head(url, accept: 'html')
61
+ expect(response).to eq("Content-Type"=>"text/html")
62
+ expect(stub).to have_been_requested
63
+ end
64
+ end
65
+
57
66
  context "empty response" do
58
67
  it "get json" do
59
68
  stub = stub_request(:get, url).to_return(:body => nil, :status => 200, :headers => { "Content-Type" => "application/json" })
@@ -255,6 +264,12 @@ describe Maremma do
255
264
  response = subject.get(url, limit: 1)
256
265
  expect(response).to eq("errors"=>[{"status"=>400, "title"=>"too many redirects; last one to: http://www.example.org/redirect/x"}])
257
266
  end
267
+
268
+ it "redirect limit 0 head" do
269
+ stub_request(:head, url).to_return(status: 301, headers: { location: redirect_url })
270
+ response = subject.head(url, limit: 0)
271
+ expect(response["Location"]).to eq("http://www.example.org/redirect")
272
+ end
258
273
  end
259
274
 
260
275
  context "content negotiation" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maremma
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.3
4
+ version: 2.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Fenner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-11 00:00:00.000000000 Z
11
+ date: 2017-08-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -72,14 +72,20 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 1.6.7
75
+ version: '1.6'
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: 1.6.8
76
79
  type: :runtime
77
80
  prerelease: false
78
81
  version_requirements: !ruby/object:Gem::Requirement
79
82
  requirements:
80
83
  - - "~>"
81
84
  - !ruby/object:Gem::Version
82
- version: 1.6.7
85
+ version: '1.6'
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: 1.6.8
83
89
  - !ruby/object:Gem::Dependency
84
90
  name: builder
85
91
  requirement: !ruby/object:Gem::Requirement