mint_http 0.1.12 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +15 -0
- data/Gemfile +4 -4
- data/Gemfile.lock +8 -2
- data/lib/mint_http/errors.rb +64 -0
- data/lib/mint_http/net_http_factory.rb +3 -0
- data/lib/mint_http/request.rb +41 -0
- data/lib/mint_http/response.rb +6 -0
- data/lib/mint_http/version.rb +1 -1
- data/lib/mint_http.rb +1 -6
- metadata +18 -9
- data/lib/mint_http/errors/authentication_error.rb +0 -4
- data/lib/mint_http/errors/authorization_error.rb +0 -4
- data/lib/mint_http/errors/client_error.rb +0 -4
- data/lib/mint_http/errors/not_found_error.rb +0 -4
- data/lib/mint_http/errors/response_error.rb +0 -15
- data/lib/mint_http/errors/server_error.rb +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7876c7512848424e65ae274b51518aafda63775252fdbfa1b1d80641137036f1
|
4
|
+
data.tar.gz: 358de110ee10df9e2ba006f9589c16ee659de0f1c902f3d07b12cfd684b7c21f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ce4427818dbf5ed767770e5307213dcc19f3fc9a510b1527679e94f418c3671236fc863ba140155b343d7f120a91c07092007b79821f60ad6312f66ecdfebb0
|
7
|
+
data.tar.gz: dce9c8920f2f4dfc25a41f3fa4680117ebf686cee000a0aeb1cf18424f24fcb54e439d4ab116eedf2776eb962fc297ba6505a501603a080b58983ea53adce55f
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,20 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [1.0.1] - 2025-05-26
|
4
|
+
|
5
|
+
- Add SSL min and max version support
|
6
|
+
|
7
|
+
## [1.0.0] - 2024-11-05
|
8
|
+
|
9
|
+
- Improve error handling by introducing new error base class that makes it easy for users to catch and deal with errors.
|
10
|
+
- Add more HTTP error classes.
|
11
|
+
|
12
|
+
|
13
|
+
## [0.1.12] - 2024-10-13
|
14
|
+
|
15
|
+
- Fix Logging when server returns a UTF-8 response with invalid encoding set in header
|
16
|
+
|
17
|
+
|
3
18
|
## [0.1.0] - 2023-07-03
|
4
19
|
|
5
20
|
- Initial release
|
data/Gemfile
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
source
|
3
|
+
source 'https://rubygems.org'
|
4
4
|
|
5
5
|
# Specify your gem's dependencies in mint_http.gemspec
|
6
6
|
gemspec
|
7
7
|
|
8
|
-
gem
|
9
|
-
|
10
|
-
gem
|
8
|
+
gem 'rake', '~> 13.0'
|
9
|
+
gem 'minitest', '~> 5.0'
|
10
|
+
gem 'resolv-replace'
|
data/Gemfile.lock
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
mint_http (0.1
|
4
|
+
mint_http (1.0.1)
|
5
5
|
base64
|
6
6
|
json
|
7
7
|
net-http
|
8
8
|
openssl
|
9
|
+
resolv
|
9
10
|
uri
|
10
11
|
|
11
12
|
GEM
|
@@ -18,15 +19,20 @@ GEM
|
|
18
19
|
uri
|
19
20
|
openssl (3.2.0)
|
20
21
|
rake (13.0.6)
|
22
|
+
resolv (0.4.0)
|
23
|
+
resolv-replace (0.1.1)
|
24
|
+
resolv
|
21
25
|
uri (0.13.0)
|
22
26
|
|
23
27
|
PLATFORMS
|
24
28
|
arm64-darwin-22
|
29
|
+
arm64-darwin-23
|
25
30
|
|
26
31
|
DEPENDENCIES
|
27
32
|
minitest (~> 5.0)
|
28
33
|
mint_http!
|
29
34
|
rake (~> 13.0)
|
35
|
+
resolv-replace
|
30
36
|
|
31
37
|
BUNDLED WITH
|
32
|
-
2.
|
38
|
+
2.5.6
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module MintHttp
|
4
|
+
class Error < StandardError; end
|
5
|
+
|
6
|
+
# Errno::EHOSTUNREACH: The network host is unreachable, often due to network configuration issues or connectivity problems.
|
7
|
+
# ENETUNREACH
|
8
|
+
class ConnectionError < Error; end
|
9
|
+
|
10
|
+
# Errno::ECONNREFUSED: The connection was refused by the remote server, often because the port is closed or the server is not running.
|
11
|
+
class ConnectionRefusedError < ConnectionError; end
|
12
|
+
|
13
|
+
# Errno::ECONNRESET: The connection was reset by the peer (the other end of the connection), typically due to abrupt disconnection.
|
14
|
+
class ConnectionResetError < ConnectionError; end
|
15
|
+
|
16
|
+
# Errno::ECONNABORTED: The connection was aborted, often due to the network or the other side abruptly closing the connection.
|
17
|
+
class ConnectionAbortedError < ConnectionError; end
|
18
|
+
|
19
|
+
# IOError
|
20
|
+
# EOFError: Raised when an end-of-file condition is reached, often indicating that the connection was closed by the peer during reading.
|
21
|
+
# Errno::EPIPE: Writing to a closed socket results in this error, indicating a "broken pipe."
|
22
|
+
# Errno::EIO: Input/output error, typically indicating an issue with reading or writing to the socket due to a system-level error.
|
23
|
+
class ConnectionIoError < ConnectionError; end
|
24
|
+
|
25
|
+
# DNS Errors
|
26
|
+
# SocketError: getaddrinfo
|
27
|
+
# Resolv::ResolvError
|
28
|
+
# Resolv::ResolvTimeout
|
29
|
+
class NameResolutionError < ConnectionError; end
|
30
|
+
|
31
|
+
# SSL Error
|
32
|
+
# OpenSSL::SSL::SSLError
|
33
|
+
class ConnectionSslError < ConnectionError; end
|
34
|
+
|
35
|
+
class TimeoutError < Error; end
|
36
|
+
class ReadTimeoutError < TimeoutError; end
|
37
|
+
class WriteTimeoutError < TimeoutError; end
|
38
|
+
class OpenTimeoutError < TimeoutError; end
|
39
|
+
|
40
|
+
class ResponseError < Error
|
41
|
+
# @return [HTTP::Response]
|
42
|
+
attr_reader :response
|
43
|
+
|
44
|
+
def initialize(msg, response)
|
45
|
+
super(msg)
|
46
|
+
@response = response
|
47
|
+
end
|
48
|
+
|
49
|
+
def to_s
|
50
|
+
response.inspect
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
class ServerError < ResponseError; end
|
55
|
+
class BadGatewayError < ServerError; end
|
56
|
+
class ServiceUnavailableError < ServerError; end
|
57
|
+
class GatewayTimeoutError < ServerError; end
|
58
|
+
|
59
|
+
|
60
|
+
class ClientError < ResponseError; end
|
61
|
+
class NotFoundError < ClientError; end
|
62
|
+
class AuthenticationError < ClientError; end
|
63
|
+
class AuthorizationError < ClientError; end
|
64
|
+
end
|
@@ -65,6 +65,9 @@ class MintHttp::NetHttpFactory
|
|
65
65
|
net_http.key = options[:key]
|
66
66
|
net_http.verify_mode = options[:verify_mode]
|
67
67
|
net_http.verify_hostname = options[:verify_hostname]
|
68
|
+
net_http.min_version = options[:min_version]
|
69
|
+
net_http.max_version = options[:max_version]
|
70
|
+
|
68
71
|
|
69
72
|
if OpenSSL::X509::Store === options[:ca]
|
70
73
|
net_http.cert_store = options[:ca]
|
data/lib/mint_http/request.rb
CHANGED
@@ -5,6 +5,7 @@ require 'net/http'
|
|
5
5
|
require 'uri'
|
6
6
|
require 'openssl'
|
7
7
|
require 'json'
|
8
|
+
require 'resolv'
|
8
9
|
|
9
10
|
module MintHttp
|
10
11
|
class Request
|
@@ -22,6 +23,8 @@ module MintHttp
|
|
22
23
|
attr_reader :proxy_port
|
23
24
|
attr_reader :ssl_verify_mode
|
24
25
|
attr_reader :ssl_verify_hostname
|
26
|
+
attr_reader :ssl_min_version
|
27
|
+
attr_reader :ssl_max_version
|
25
28
|
|
26
29
|
# Attributes only available when request is made
|
27
30
|
attr_reader :method
|
@@ -47,6 +50,8 @@ module MintHttp
|
|
47
50
|
@proxy_pass = nil
|
48
51
|
@ssl_verify_mode = nil
|
49
52
|
@ssl_verify_hostname = nil
|
53
|
+
@ssl_min_version = nil
|
54
|
+
@ssl_max_version = nil
|
50
55
|
|
51
56
|
@logger = MintHttp.config.logger
|
52
57
|
@filter_params_list = MintHttp.config.filter_params_list
|
@@ -88,6 +93,12 @@ module MintHttp
|
|
88
93
|
self
|
89
94
|
end
|
90
95
|
|
96
|
+
def ssl_version(min, max)
|
97
|
+
@ssl_min_version = min
|
98
|
+
@ssl_max_version = max
|
99
|
+
self
|
100
|
+
end
|
101
|
+
|
91
102
|
def use_ca(ca)
|
92
103
|
@ca = ca
|
93
104
|
self
|
@@ -281,6 +292,7 @@ module MintHttp
|
|
281
292
|
logger.log_end
|
282
293
|
logger.log_error(error)
|
283
294
|
logger.write_log
|
295
|
+
|
284
296
|
raise error
|
285
297
|
end
|
286
298
|
|
@@ -293,6 +305,33 @@ module MintHttp
|
|
293
305
|
logger.write_log
|
294
306
|
|
295
307
|
response
|
308
|
+
|
309
|
+
rescue SocketError => e
|
310
|
+
if e.message.include?('getaddrinfo') || e.cause.is_a?(Resolv::ResolvError) || e.cause.is_a?(Resolv::ResolvTimeout)
|
311
|
+
raise NameResolutionError, e.message
|
312
|
+
else
|
313
|
+
raise ConnectionIoError, e.message
|
314
|
+
end
|
315
|
+
|
316
|
+
rescue Net::OpenTimeout => e
|
317
|
+
raise OpenTimeoutError, e.message
|
318
|
+
rescue Net::WriteTimeout => e
|
319
|
+
raise WriteTimeoutError, e.message
|
320
|
+
rescue Net::ReadTimeout => e
|
321
|
+
raise ReadTimeoutError, e.message
|
322
|
+
|
323
|
+
rescue Errno::ECONNREFUSED => e
|
324
|
+
raise ConnectionRefusedError, e.message
|
325
|
+
rescue Errno::ECONNRESET => e
|
326
|
+
raise ConnectionResetError, e.message
|
327
|
+
|
328
|
+
rescue IOError, EOFError, Errno::EPIPE, Errno::EIO => e
|
329
|
+
raise ConnectionIoError, e.message
|
330
|
+
rescue Errno::EHOSTUNREACH, Errno::ENETUNREACH => e
|
331
|
+
raise ConnectionError, e.message
|
332
|
+
|
333
|
+
rescue OpenSSL::SSL::SSLError => e
|
334
|
+
raise ConnectionSslError, e.message
|
296
335
|
end
|
297
336
|
|
298
337
|
private
|
@@ -387,6 +426,8 @@ module MintHttp
|
|
387
426
|
proxy_pass: @proxy_pass,
|
388
427
|
verify_mode: @ssl_verify_mode,
|
389
428
|
verify_hostname: @ssl_verify_hostname,
|
429
|
+
min_version: @ssl_min_version,
|
430
|
+
max_version: @ssl_max_version,
|
390
431
|
}
|
391
432
|
|
392
433
|
[url, net_request, options]
|
data/lib/mint_http/response.rb
CHANGED
@@ -85,6 +85,12 @@ module MintHttp
|
|
85
85
|
raise AuthorizationError.new('Forbidden', self)
|
86
86
|
when 404
|
87
87
|
raise NotFoundError.new('Not Found', self)
|
88
|
+
when 502
|
89
|
+
raise BadGatewayError.new('Bad Gateway', self)
|
90
|
+
when 503
|
91
|
+
raise ServiceUnavailableError.new('Service Unavailable', self)
|
92
|
+
when 504
|
93
|
+
raise GatewayTimeoutError.new('Gateway Timeout', self)
|
88
94
|
when 400..499
|
89
95
|
raise ClientError.new('Client Error', self)
|
90
96
|
when 500..599
|
data/lib/mint_http/version.rb
CHANGED
data/lib/mint_http.rb
CHANGED
@@ -7,12 +7,7 @@ require_relative 'mint_http/config'
|
|
7
7
|
require_relative 'mint_http/pool_entry'
|
8
8
|
require_relative 'mint_http/pool'
|
9
9
|
require_relative 'mint_http/headers'
|
10
|
-
require_relative 'mint_http/errors
|
11
|
-
require_relative 'mint_http/errors/server_error'
|
12
|
-
require_relative 'mint_http/errors/client_error'
|
13
|
-
require_relative 'mint_http/errors/authorization_error'
|
14
|
-
require_relative 'mint_http/errors/authentication_error'
|
15
|
-
require_relative 'mint_http/errors/not_found_error'
|
10
|
+
require_relative 'mint_http/errors'
|
16
11
|
require_relative 'mint_http/net_http_factory'
|
17
12
|
require_relative 'mint_http/request_logger'
|
18
13
|
require_relative 'mint_http/response'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mint_http
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ali Alhoshaiyan
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-05-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: net-http
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: resolv
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
83
97
|
description: Like a mint breeze, MintHttp allows you to write simple HTTP requests
|
84
98
|
while giving you the full power of Net::HTTP.
|
85
99
|
email:
|
@@ -96,12 +110,7 @@ files:
|
|
96
110
|
- Rakefile
|
97
111
|
- lib/mint_http.rb
|
98
112
|
- lib/mint_http/config.rb
|
99
|
-
- lib/mint_http/errors
|
100
|
-
- lib/mint_http/errors/authorization_error.rb
|
101
|
-
- lib/mint_http/errors/client_error.rb
|
102
|
-
- lib/mint_http/errors/not_found_error.rb
|
103
|
-
- lib/mint_http/errors/response_error.rb
|
104
|
-
- lib/mint_http/errors/server_error.rb
|
113
|
+
- lib/mint_http/errors.rb
|
105
114
|
- lib/mint_http/headers.rb
|
106
115
|
- lib/mint_http/net_http_factory.rb
|
107
116
|
- lib/mint_http/pool.rb
|
@@ -132,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
132
141
|
- !ruby/object:Gem::Version
|
133
142
|
version: '0'
|
134
143
|
requirements: []
|
135
|
-
rubygems_version: 3.
|
144
|
+
rubygems_version: 3.5.11
|
136
145
|
signing_key:
|
137
146
|
specification_version: 4
|
138
147
|
summary: A small fluent HTTP client.
|
@@ -1,15 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class MintHttp::ResponseError < StandardError
|
4
|
-
# @return [HTTP::Response]
|
5
|
-
attr_reader :response
|
6
|
-
|
7
|
-
def initialize(msg, response)
|
8
|
-
super(msg)
|
9
|
-
@response = response
|
10
|
-
end
|
11
|
-
|
12
|
-
def to_s
|
13
|
-
response.inspect
|
14
|
-
end
|
15
|
-
end
|