rdap 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -0
  3. data/lib/rdap.rb +8 -1
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2a99673df539bd98e21a4e72d6016395e4d287242b7e4c32c51db227de855f25
4
- data.tar.gz: 67d8b8e7bc6a7d6810aaef71405d9a52dad469e4d8472e596cf4833b3e5b9301
3
+ metadata.gz: e381820dc8920d506d751cf7c1d562dd4f7bcaac07aeec9c735bad6777a41019
4
+ data.tar.gz: 2a5c7562f80f162d88b24a999e67e9ae3cba5b677ff84aab48adfc5ae1c3df7d
5
5
  SHA512:
6
- metadata.gz: 32a03c18914f4898eb292013cae6d424ac085c04c1fb944e2d91b07c1d25356382cee2bc736852c4dcdf824d74ff17a5ce7d6c94a16161bc13b65fdae5f6dd24
7
- data.tar.gz: a50a93ccf5f86e3942189c9356d366a9030ee863ec5492d4886e3b302c6f467306e6d1b05805c2fcfa538a5f276799ee43c9aa2adf44ee08cd90ab8b461ef218
6
+ metadata.gz: ff41ec54dd637813e4120feeb21048b179d617554da50e02db122da69a37aa066bb44eae785e1840d01b9afb19bd08182c3b8dd364e2b433ad4d89a5b1403968
7
+ data.tar.gz: 59d8e5dc3ba89b4f22025081710658b248ea062357451fd4952468cb06aba605a2123f3ce8deb0d1fea91d5690a60f4fe9f28812c4b2acaaef1ffa9289b32774
data/README.md CHANGED
@@ -84,6 +84,7 @@ The gem make a query to one of the publicly available RDAP bootstrap server (the
84
84
 
85
85
  ## Changelog
86
86
 
87
+ - **0.1.4** (2022-02-01) - Wrap JSON parser errors as RDAP::InvalidReponse and also raise RDAP::EmptyResponse when body is missing
87
88
  - **0.1.3** (2022-01-10) - Wrap SSL errors as RDAP::SSLError < ServerError < Error
88
89
  - **0.1.2** (2022-01-07) - Added HTTP headers customization
89
90
  - **0.1.1** (2021-12-19) - Added TooManyRequests expection in case of 429
data/lib/rdap.rb CHANGED
@@ -2,7 +2,7 @@ require 'json'
2
2
  require 'net/http'
3
3
 
4
4
  module RDAP
5
- VERSION = "0.1.3"
5
+ VERSION = "0.1.4"
6
6
  BOOTSTRAP = "https://rdap.org/"
7
7
  TYPES = [:domain, :ip, :autnum].freeze
8
8
  HEADERS = {
@@ -13,6 +13,8 @@ module RDAP
13
13
  class Error < StandardError; end
14
14
  class ServerError < Error; end
15
15
  class SSLError < ServerError; end
16
+ class EmptyResponse < ServerError; end
17
+ class InvalidResponse < ServerError; end
16
18
  class NotFound < Error; end
17
19
  class TooManyRequests < Error; end
18
20
 
@@ -48,6 +50,9 @@ module RDAP
48
50
  response = http.get(uri.path, HEADERS.merge(headers))
49
51
  case response
50
52
  when Net::HTTPSuccess
53
+ if !response.body
54
+ raise EmptyResponse.new("[#{response.code}] #{response.message}")
55
+ end
51
56
  document = JSON.parse(response.body)
52
57
  if document["errorCode"]
53
58
  raise ServerError.new("[#{document["errorCode"]}] #{document["title"]} (#{uri})")
@@ -69,5 +74,7 @@ module RDAP
69
74
  end
70
75
  rescue OpenSSL::SSL::SSLError => e
71
76
  raise SSLError.new("#{e.message} (#{uri.host})")
77
+ rescue JSON::ParserError => e
78
+ raise InvalidResponse.new("JSON parser error: #{e.message}")
72
79
  end
73
80
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrien Rey-Jarthon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-10 00:00:00.000000000 Z
11
+ date: 2022-02-01 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: