rdap 0.1.3 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +18 -18
  3. data/README.md +2 -0
  4. data/lib/rdap.rb +10 -2
  5. metadata +7 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2a99673df539bd98e21a4e72d6016395e4d287242b7e4c32c51db227de855f25
4
- data.tar.gz: 67d8b8e7bc6a7d6810aaef71405d9a52dad469e4d8472e596cf4833b3e5b9301
3
+ metadata.gz: c581a8dc72e90041dca43e12e4ae618cc04dd45287326f561c20c4288da3c474
4
+ data.tar.gz: 5a89c282b3fa0dd1ff9b26385ec1e226fa81e379cac126af2356d8f53874a699
5
5
  SHA512:
6
- metadata.gz: 32a03c18914f4898eb292013cae6d424ac085c04c1fb944e2d91b07c1d25356382cee2bc736852c4dcdf824d74ff17a5ce7d6c94a16161bc13b65fdae5f6dd24
7
- data.tar.gz: a50a93ccf5f86e3942189c9356d366a9030ee863ec5492d4886e3b302c6f467306e6d1b05805c2fcfa538a5f276799ee43c9aa2adf44ee08cd90ab8b461ef218
6
+ metadata.gz: b2b6feb519a91e27515cc97d05d23c82feef65b8dfb6c8eee8e8096d3b7ae39304061a4a09713addf34ec415f722544e4a3b5e6e744c8cb379b78b6a7fc3bfbc
7
+ data.tar.gz: d1d9276926e98654b6fb30d0885d580c495d51f0b23718854128a2c3c8232f38de92a3f777eda482c0a852dc00661c01cff9dc03980ff15a52d2c7645fdd66cc
data/Gemfile.lock CHANGED
@@ -1,35 +1,35 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rdap (0.1.1)
4
+ rdap (0.1.4)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- addressable (2.8.0)
10
- public_suffix (>= 2.0.2, < 5.0)
9
+ addressable (2.8.1)
10
+ public_suffix (>= 2.0.2, < 6.0)
11
11
  crack (0.4.5)
12
12
  rexml
13
- diff-lcs (1.4.4)
13
+ diff-lcs (1.5.0)
14
14
  hashdiff (1.0.1)
15
- public_suffix (4.0.6)
15
+ public_suffix (5.0.1)
16
16
  rake (13.0.6)
17
17
  rexml (3.2.5)
18
- rspec (3.10.0)
19
- rspec-core (~> 3.10.0)
20
- rspec-expectations (~> 3.10.0)
21
- rspec-mocks (~> 3.10.0)
22
- rspec-core (3.10.1)
23
- rspec-support (~> 3.10.0)
24
- rspec-expectations (3.10.1)
18
+ rspec (3.12.0)
19
+ rspec-core (~> 3.12.0)
20
+ rspec-expectations (~> 3.12.0)
21
+ rspec-mocks (~> 3.12.0)
22
+ rspec-core (3.12.0)
23
+ rspec-support (~> 3.12.0)
24
+ rspec-expectations (3.12.1)
25
25
  diff-lcs (>= 1.2.0, < 2.0)
26
- rspec-support (~> 3.10.0)
27
- rspec-mocks (3.10.2)
26
+ rspec-support (~> 3.12.0)
27
+ rspec-mocks (3.12.1)
28
28
  diff-lcs (>= 1.2.0, < 2.0)
29
- rspec-support (~> 3.10.0)
30
- rspec-support (3.10.3)
31
- vcr (6.0.0)
32
- webmock (3.14.0)
29
+ rspec-support (~> 3.12.0)
30
+ rspec-support (3.12.0)
31
+ vcr (6.1.0)
32
+ webmock (3.18.1)
33
33
  addressable (>= 2.8.0)
34
34
  crack (>= 0.3.2)
35
35
  hashdiff (>= 0.4.0, < 2.0.0)
data/README.md CHANGED
@@ -84,6 +84,8 @@ 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.5** (2022-12-29) - Add `application/json, */*` fallback Accept types to support rdap.nic.fr which does not like `application/rdap+json` (as of 2022-12-29). I also contacted them to report this issue.
88
+ - **0.1.4** (2022-02-01) - Wrap JSON parser errors as RDAP::InvalidReponse and also raise RDAP::EmptyResponse when body is missing
87
89
  - **0.1.3** (2022-01-10) - Wrap SSL errors as RDAP::SSLError < ServerError < Error
88
90
  - **0.1.2** (2022-01-07) - Added HTTP headers customization
89
91
  - **0.1.1** (2021-12-19) - Added TooManyRequests expection in case of 429
data/lib/rdap.rb CHANGED
@@ -2,17 +2,20 @@ require 'json'
2
2
  require 'net/http'
3
3
 
4
4
  module RDAP
5
- VERSION = "0.1.3"
5
+ VERSION = "0.1.5"
6
6
  BOOTSTRAP = "https://rdap.org/"
7
7
  TYPES = [:domain, :ip, :autnum].freeze
8
8
  HEADERS = {
9
9
  "User-Agent" => "RDAP ruby gem (#{VERSION})",
10
- "Accept" => "application/rdap+json"
10
+ "Accept" => "application/rdap+json, application/json, */*;q=0.8",
11
+ # Had to include other types here because rdap.nic.fr returns an error with only rdap+json -_-
11
12
  }
12
13
 
13
14
  class Error < StandardError; end
14
15
  class ServerError < Error; end
15
16
  class SSLError < ServerError; end
17
+ class EmptyResponse < ServerError; end
18
+ class InvalidResponse < ServerError; end
16
19
  class NotFound < Error; end
17
20
  class TooManyRequests < Error; end
18
21
 
@@ -48,6 +51,9 @@ module RDAP
48
51
  response = http.get(uri.path, HEADERS.merge(headers))
49
52
  case response
50
53
  when Net::HTTPSuccess
54
+ if !response.body
55
+ raise EmptyResponse.new("[#{response.code}] #{response.message}")
56
+ end
51
57
  document = JSON.parse(response.body)
52
58
  if document["errorCode"]
53
59
  raise ServerError.new("[#{document["errorCode"]}] #{document["title"]} (#{uri})")
@@ -69,5 +75,7 @@ module RDAP
69
75
  end
70
76
  rescue OpenSSL::SSL::SSLError => e
71
77
  raise SSLError.new("#{e.message} (#{uri.host})")
78
+ rescue JSON::ParserError => e
79
+ raise InvalidResponse.new("JSON parser error: #{e.message}")
72
80
  end
73
81
  end
metadata CHANGED
@@ -1,16 +1,16 @@
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.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrien Rey-Jarthon
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-10 00:00:00.000000000 Z
11
+ date: 2022-12-29 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description:
13
+ description:
14
14
  email:
15
15
  - jobs@adrienjarthon.com
16
16
  executables: []
@@ -29,7 +29,7 @@ files:
29
29
  homepage: https://github.com/jarthod/rdap
30
30
  licenses: []
31
31
  metadata: {}
32
- post_install_message:
32
+ post_install_message:
33
33
  rdoc_options: []
34
34
  require_paths:
35
35
  - lib
@@ -44,8 +44,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
44
44
  - !ruby/object:Gem::Version
45
45
  version: '0'
46
46
  requirements: []
47
- rubygems_version: 3.3.0
48
- signing_key:
47
+ rubygems_version: 3.3.7
48
+ signing_key:
49
49
  specification_version: 4
50
50
  summary: A minimal Ruby client to query RDAP APIs though a bootstrap server
51
51
  test_files: []