mini_http 0.1.0 → 0.2.0
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 +13 -0
- data/README.md +23 -0
- data/lib/mini_http/version.rb +1 -1
- data/lib/mini_http.rb +23 -14
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 990e61a5e8156abfcba0c67c1e4389e22af16db7c0f691e2b80c280e949aef14
|
|
4
|
+
data.tar.gz: d5d4068593c054c35e0a8c6ef0fcc6fcfd04703aafe6bf8c2dfb02711f04cd81
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8009ad9d56b6a21585ec6a78dabe16cb06c687e7253387e43c6cdbfef4162d503fe313165528d080414f467111efc04450dd6cc5b8b74b061535c2721276e3fc
|
|
7
|
+
data.tar.gz: 21943e04397015929abd169882b444e56bf861284f29b5cd29cba1b4451b62705cb2650e43e1ccb49e6fdd3cbefcb5ed597a0bcb4e82e2e57b12b0f0377dc29b
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
## [0.2.0] - 2025-12-02
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
- Added `ssl` option to disable SSL certificate verification for development environments
|
|
7
|
+
- SSL verification can now be disabled by passing `ssl: false` to any HTTP method
|
|
8
|
+
|
|
9
|
+
### Changed
|
|
10
|
+
- Refactored parameter handling to use keyword arguments splat (`**options`) to comply with RuboCop metrics
|
|
11
|
+
- Improved code maintainability by reducing parameter count in method signatures
|
|
12
|
+
|
|
13
|
+
### Fixed
|
|
14
|
+
- Fixed RuboCop Metrics/ParameterLists violation
|
|
15
|
+
|
|
3
16
|
## [0.1.0] - 2025-06-23
|
|
4
17
|
|
|
5
18
|
- Initial release of MiniHttp
|
data/README.md
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+

|
|
2
|
+
|
|
3
|
+
|
|
1
4
|
# MiniHttp
|
|
2
5
|
|
|
3
6
|
A minimal, lightweight HTTP client library for Ruby that provides a clean interface for making HTTP requests with automatic JSON handling, SSL support, and customizable timeouts.
|
|
@@ -103,6 +106,7 @@ All methods support these optional parameters:
|
|
|
103
106
|
- `headers`: Hash of HTTP headers
|
|
104
107
|
- `timeout`: Request timeout in seconds (default: 30)
|
|
105
108
|
- `body`: Request body for POST/PUT (string or object that responds to `to_json`)
|
|
109
|
+
- `ssl`: Enable/disable SSL certificate verification (default: true)
|
|
106
110
|
|
|
107
111
|
```ruby
|
|
108
112
|
response = MiniHttp.get(
|
|
@@ -115,6 +119,25 @@ response = MiniHttp.get(
|
|
|
115
119
|
)
|
|
116
120
|
```
|
|
117
121
|
|
|
122
|
+
### Disabling SSL verification (for development)
|
|
123
|
+
|
|
124
|
+
⚠️ **Warning**: Only use this in development environments. Never disable SSL verification in production.
|
|
125
|
+
|
|
126
|
+
```ruby
|
|
127
|
+
# Useful for testing with self-signed certificates in development
|
|
128
|
+
response = MiniHttp.get(
|
|
129
|
+
"https://localhost:3000/api/data",
|
|
130
|
+
ssl: false
|
|
131
|
+
)
|
|
132
|
+
|
|
133
|
+
# Works with all HTTP methods
|
|
134
|
+
response = MiniHttp.post(
|
|
135
|
+
"https://dev-api.local/users",
|
|
136
|
+
body: { name: "Test User" },
|
|
137
|
+
ssl: false
|
|
138
|
+
)
|
|
139
|
+
```
|
|
140
|
+
|
|
118
141
|
## Development
|
|
119
142
|
|
|
120
143
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/mini_http/version.rb
CHANGED
data/lib/mini_http.rb
CHANGED
|
@@ -51,46 +51,55 @@ class MiniHttp
|
|
|
51
51
|
end
|
|
52
52
|
end
|
|
53
53
|
|
|
54
|
-
def self.get(url,
|
|
55
|
-
make_request(:get, url,
|
|
54
|
+
def self.get(url, **options)
|
|
55
|
+
make_request(:get, url, **options)
|
|
56
56
|
end
|
|
57
57
|
|
|
58
|
-
def self.post(url,
|
|
59
|
-
make_request(:post, url,
|
|
58
|
+
def self.post(url, **options)
|
|
59
|
+
make_request(:post, url, **options)
|
|
60
60
|
end
|
|
61
61
|
|
|
62
|
-
def self.put(url,
|
|
63
|
-
make_request(:put, url,
|
|
62
|
+
def self.put(url, **options)
|
|
63
|
+
make_request(:put, url, **options)
|
|
64
64
|
end
|
|
65
65
|
|
|
66
|
-
def self.delete(url,
|
|
67
|
-
make_request(:delete, url,
|
|
66
|
+
def self.delete(url, **options)
|
|
67
|
+
make_request(:delete, url, **options)
|
|
68
68
|
end
|
|
69
69
|
|
|
70
70
|
class << self
|
|
71
71
|
private
|
|
72
72
|
|
|
73
|
-
def make_request(method, url,
|
|
73
|
+
def make_request(method, url, **options)
|
|
74
|
+
body = options[:body]
|
|
75
|
+
headers = options.fetch(:headers, {})
|
|
76
|
+
timeout = options.fetch(:timeout, 30)
|
|
77
|
+
ssl = options.fetch(:ssl, true)
|
|
78
|
+
|
|
74
79
|
uri = URI(url)
|
|
75
|
-
http = build_http_client(uri, timeout)
|
|
80
|
+
http = build_http_client(uri, timeout, ssl)
|
|
76
81
|
request = build_request(method, uri, body, headers)
|
|
77
82
|
|
|
78
83
|
net_response = http.request(request)
|
|
79
84
|
Response.new(net_response)
|
|
80
85
|
end
|
|
81
86
|
|
|
82
|
-
def build_http_client(uri, timeout)
|
|
87
|
+
def build_http_client(uri, timeout, ssl)
|
|
83
88
|
http = Net::HTTP.new(uri.host, uri.port)
|
|
84
|
-
configure_ssl(http, uri)
|
|
89
|
+
configure_ssl(http, uri, ssl)
|
|
85
90
|
configure_timeouts(http, timeout)
|
|
86
91
|
http
|
|
87
92
|
end
|
|
88
93
|
|
|
89
|
-
def configure_ssl(http, uri)
|
|
94
|
+
def configure_ssl(http, uri, ssl)
|
|
90
95
|
return unless uri.scheme == "https"
|
|
91
96
|
|
|
92
97
|
http.use_ssl = true
|
|
93
|
-
http.verify_mode =
|
|
98
|
+
http.verify_mode = if ssl
|
|
99
|
+
OpenSSL::SSL::VERIFY_PEER
|
|
100
|
+
else
|
|
101
|
+
OpenSSL::SSL::VERIFY_NONE
|
|
102
|
+
end
|
|
94
103
|
end
|
|
95
104
|
|
|
96
105
|
def configure_timeouts(http, timeout)
|