mint_http 1.0.1 → 1.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7876c7512848424e65ae274b51518aafda63775252fdbfa1b1d80641137036f1
4
- data.tar.gz: 358de110ee10df9e2ba006f9589c16ee659de0f1c902f3d07b12cfd684b7c21f
3
+ metadata.gz: 81270d63b70e3b2fbedce35352c6be839dc1cd56733cc3444e9c14abc562b048
4
+ data.tar.gz: b324e059ba388938dd2a2db8d7dfe78f0c17e51a903b334af17d7584b350770e
5
5
  SHA512:
6
- metadata.gz: 2ce4427818dbf5ed767770e5307213dcc19f3fc9a510b1527679e94f418c3671236fc863ba140155b343d7f120a91c07092007b79821f60ad6312f66ecdfebb0
7
- data.tar.gz: dce9c8920f2f4dfc25a41f3fa4680117ebf686cee000a0aeb1cf18424f24fcb54e439d4ab116eedf2776eb962fc297ba6505a501603a080b58983ea53adce55f
6
+ metadata.gz: 765ce835680a70f841ad6e697ea1e687525fb89434339bf1359ccfaeb1550733f75aa7e5bc0ff9175682a3ab4487b324dc2d3c0302c3553b95436551f4a9725f
7
+ data.tar.gz: 6d6fb7f1b2cb3668c95e556b9457b55d70fc2f0b3a5696931fedc19717fcff1c0102119736384e10ca1831f4176cf7681cea63248c711a013b458fc7b4e1c5d8
data/Gemfile CHANGED
@@ -8,3 +8,4 @@ gemspec
8
8
  gem 'rake', '~> 13.0'
9
9
  gem 'minitest', '~> 5.0'
10
10
  gem 'resolv-replace'
11
+ gem 'mutex_m'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mint_http (1.0.1)
4
+ mint_http (1.1.0)
5
5
  base64
6
6
  json
7
7
  net-http
@@ -15,6 +15,7 @@ GEM
15
15
  base64 (0.2.0)
16
16
  json (2.7.2)
17
17
  minitest (5.18.0)
18
+ mutex_m (0.2.0)
18
19
  net-http (0.4.1)
19
20
  uri
20
21
  openssl (3.2.0)
@@ -27,10 +28,12 @@ GEM
27
28
  PLATFORMS
28
29
  arm64-darwin-22
29
30
  arm64-darwin-23
31
+ arm64-darwin-24
30
32
 
31
33
  DEPENDENCIES
32
34
  minitest (~> 5.0)
33
35
  mint_http!
36
+ mutex_m
34
37
  rake (~> 13.0)
35
38
  resolv-replace
36
39
 
data/http.log ADDED
@@ -0,0 +1,692 @@
1
+ I, [2024-07-20T17:01:40.725955 #38292] INFO -- : MintHttp Log (https://api.moyasar.com)
2
+ @@ Timeouts: 5, 5, 20
3
+ @@ Time: 619603.133 -> 619603.425 connecting: 0.292 total: 0.395 seconds
4
+ @@ TLS: TLSv1.2 Cipher: ECDHE-RSA-AES128-GCM-SHA256
5
+ -> POST HTTP/1.1
6
+ -> Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
7
+ -> Accept: application/json
8
+ -> User-Agent: Mint Http
9
+ -> Host: api.moyasar.com
10
+ -> Content-Type: application/json
11
+ -> Content-Length: 13
12
+ -> {"foo":"bar"}
13
+ =======
14
+ <- Response: HTTP/1.1 404 Not Found
15
+ <- Date: Sat, 20 Jul 2024 14:01:40 GMT
16
+ <- Content-Type: application/json; charset=utf-8
17
+ <- Content-Length: 91
18
+ <- Connection: keep-alive
19
+ <- X-Frame-Options: SAMEORIGIN
20
+ <- X-Xss-Protection: 0
21
+ <- X-Content-Type-Options: nosniff
22
+ <- X-Download-Options: noopen
23
+ <- X-Permitted-Cross-Domain-Policies: none
24
+ <- Referrer-Policy: strict-origin-when-cross-origin
25
+ <- X-Request-Id: b1b4dd16-ffff-4e75-96d6-0752264ab291
26
+ <- X-Runtime: 0.005768
27
+ <- Strict-Transport-Security: max-age=63072000; includeSubDomains
28
+ <- Vary: Origin
29
+ <- Length: 91 Body: {
30
+ "type": "invalid_request_error",
31
+ "message": "Resource not found",
32
+ "errors": null
33
+ }
34
+ I, [2024-07-20T17:01:42.689559 #38292] INFO -- : MintHttp Log (https://ipinfo.com/1.1.1.1)
35
+ @@ Timeouts: 5, 5, 20
36
+ @@ Time: 619604.935 -> 619605.308 connecting: 0.373 total: 0.556 seconds
37
+ @@ TLS: TLSv1.3 Cipher: TLS_AES_256_GCM_SHA384
38
+ -> POST /1.1.1.1 HTTP/1.1
39
+ -> Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
40
+ -> Accept: application/json
41
+ -> User-Agent: Mint Http
42
+ -> Host: ipinfo.com
43
+ -> Content-Type: application/json
44
+ -> Content-Length: 13
45
+ -> {"foo":"bar"}
46
+ =======
47
+ <- Response: HTTP/1.1 404 Not Found
48
+ <- Date: Sat, 20 Jul 2024 14:01:42 GMT
49
+ <- Server: Apache
50
+ <- Content-Length: 315
51
+ <- Content-Type: text/html; charset=iso-8859-1
52
+ <- Length: 315 Body: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
53
+ <html><head>
54
+ <title>404 Not Found</title>
55
+ </head><body>
56
+ <h1>Not Found</h1>
57
+ <p>The requested URL was not found on this server.</p>
58
+ <p>Additionally, a 404 Not Found
59
+ error was encountered while trying to use an ErrorDocument to handle the request.</p>
60
+ </body></html>
61
+ I, [2024-07-20T17:01:43.075798 #38292] INFO -- : MintHttp Log (https://jsonplaceholder.typicode.com/todos)
62
+ @@ Timeouts: 5, 5, 20
63
+ @@ Time: 619605.492 -> 619605.671 connecting: 0.179 total: 0.385 seconds
64
+ @@ TLS: TLSv1.3 Cipher: TLS_AES_256_GCM_SHA384
65
+ -> POST /todos HTTP/1.1
66
+ -> Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
67
+ -> Accept: application/json
68
+ -> User-Agent: Mint Http
69
+ -> Host: jsonplaceholder.typicode.com
70
+ -> Content-Type: application/json
71
+ -> Content-Length: 13
72
+ -> {"foo":"bar"}
73
+ =======
74
+ <- Response: HTTP/1.1 201 Created
75
+ <- Date: Sat, 20 Jul 2024 14:01:43 GMT
76
+ <- Content-Type: application/json; charset=utf-8
77
+ <- Content-Length: 31
78
+ <- Connection: keep-alive
79
+ <- Report-To: {"group":"heroku-nel","max_age":3600,"endpoints":[{"url":"https://nel.heroku.com/reports?ts=1721484103&sid=e11707d5-02a7-43ef-b45e-2cf4d2036f7d&s=b4Wm3JpEawzMn3h85DNdBHYfHUie%2BeyhfNXaCcm4ybI%3D"}]}
80
+ <- Reporting-Endpoints: heroku-nel=https://nel.heroku.com/reports?ts=1721484103&sid=e11707d5-02a7-43ef-b45e-2cf4d2036f7d&s=b4Wm3JpEawzMn3h85DNdBHYfHUie%2BeyhfNXaCcm4ybI%3D
81
+ <- Nel: {"report_to":"heroku-nel","max_age":3600,"success_fraction":0.005,"failure_fraction":0.05,"response_headers":["Via"]}
82
+ <- X-Powered-By: Express
83
+ <- X-Ratelimit-Limit: 1000
84
+ <- X-Ratelimit-Remaining: 999
85
+ <- X-Ratelimit-Reset: 1721484152
86
+ <- Vary: Origin, X-HTTP-Method-Override, Accept-Encoding
87
+ <- Access-Control-Allow-Credentials: true
88
+ <- Cache-Control: no-cache
89
+ <- Pragma: no-cache
90
+ <- Expires: -1
91
+ <- Access-Control-Expose-Headers: Location
92
+ <- Location: https://jsonplaceholder.typicode.com/todos/201
93
+ <- X-Content-Type-Options: nosniff
94
+ <- Etag: W/"1f-v7q09ihdcrnA2mAxihAAQHEaYaQ"
95
+ <- Via: 1.1 vegur
96
+ <- Cf-Cache-Status: DYNAMIC
97
+ <- Server: cloudflare
98
+ <- Cf-Ray: 8a637c1bd939374b-MXP
99
+ <- Alt-Svc: h3=":443"; ma=86400
100
+ <- Length: 31 Body: {
101
+ "foo": "bar",
102
+ "id": 201
103
+ }
104
+ I, [2024-07-20T17:01:41.122566 #38292] INFO -- : MintHttp Log (https://api.moyasar.com/v1/payments)
105
+ @@ Timeouts: 5, 5, 20
106
+ @@ Time: 619603.534 -> 619603.822 connecting: 0.288 total: 0.39 seconds
107
+ @@ TLS: TLSv1.2 Cipher: ECDHE-RSA-AES128-GCM-SHA256
108
+ -> POST /v1/payments HTTP/1.1
109
+ -> Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
110
+ -> Accept: application/json
111
+ -> User-Agent: Mint Http
112
+ -> Host: api.moyasar.com
113
+ -> Content-Type: application/json
114
+ -> Content-Length: 13
115
+ -> {"foo":"bar"}
116
+ =======
117
+ <- Response: HTTP/1.1 401 Unauthorized
118
+ <- Date: Sat, 20 Jul 2024 14:01:41 GMT
119
+ <- Content-Type: application/json; charset=utf-8
120
+ <- Content-Length: 91
121
+ <- Connection: keep-alive
122
+ <- X-Frame-Options: SAMEORIGIN
123
+ <- X-Xss-Protection: 0
124
+ <- X-Content-Type-Options: nosniff
125
+ <- X-Download-Options: noopen
126
+ <- X-Permitted-Cross-Domain-Policies: none
127
+ <- Referrer-Policy: strict-origin-when-cross-origin
128
+ <- Www-Authenticate: Basic realm="Application"
129
+ <- Cache-Control: no-cache
130
+ <- X-Request-Id: 763be73c-965f-4a9a-9625-311451e4ae28
131
+ <- X-Runtime: 0.005780
132
+ <- Strict-Transport-Security: max-age=63072000; includeSubDomains
133
+ <- Vary: Origin
134
+ <- Length: 91 Body: {"type":"authentication_error","message":"Invalid authorization credentials","errors":null}
135
+ I, [2024-07-20T17:01:41.431665 #38292] INFO -- : MintHttp Log (https://dashboard.moyasar.com)
136
+ @@ Timeouts: 5, 5, 20
137
+ @@ Time: 619603.925 -> 619604.121 connecting: 0.196 total: 0.308 seconds
138
+ @@ TLS: TLSv1.3 Cipher: TLS_AES_128_GCM_SHA256
139
+ -> POST HTTP/1.1
140
+ -> Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
141
+ -> Accept: application/json
142
+ -> User-Agent: Mint Http
143
+ -> Host: dashboard.moyasar.com
144
+ -> Content-Type: application/json
145
+ -> Content-Length: 13
146
+ -> {"foo":"bar"}
147
+ =======
148
+ <- Response: HTTP/1.1 500 Internal Server Error
149
+ <- Date: Sat, 20 Jul 2024 14:01:41 GMT
150
+ <- Content-Type: text/plain; charset=utf-8
151
+ <- Transfer-Encoding: chunked
152
+ <- Connection: keep-alive
153
+ <- X-Request-Id: 61cd5ca0-98a2-4b11-aa7a-93aa6b999026
154
+ <- X-Runtime: 0.003495
155
+ <- Vary: Accept-Encoding
156
+ <- Strict-Transport-Security: max-age=63072000; includeSubDomains
157
+ <- Length: 182 Body: 500 Internal Server Error
158
+ If you are the administrator of this website, then please read this web application's log file and/or the web server's log file to find out what went wrong.
159
+ I, [2024-07-20T17:01:44.144972 #38292] INFO -- : MintHttp Log (https://jsonplaceholder.typicode.com/posts/1)
160
+ @@ Timeouts: 5, 5, 20
161
+ @@ Time: 619606.577 -> 619606.747 connecting: 0.17 total: 0.37 seconds
162
+ @@ TLS: TLSv1.3 Cipher: TLS_AES_256_GCM_SHA384
163
+ -> POST /posts/1 HTTP/1.1
164
+ -> Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
165
+ -> Accept: application/json
166
+ -> User-Agent: Mint Http
167
+ -> Host: jsonplaceholder.typicode.com
168
+ -> Content-Type: application/json
169
+ -> Content-Length: 13
170
+ -> {"foo":"bar"}
171
+ =======
172
+ <- Response: HTTP/1.1 404 Not Found
173
+ <- Date: Sat, 20 Jul 2024 14:01:44 GMT
174
+ <- Content-Type: application/json; charset=utf-8
175
+ <- Content-Length: 2
176
+ <- Connection: keep-alive
177
+ <- Report-To: {"group":"heroku-nel","max_age":3600,"endpoints":[{"url":"https://nel.heroku.com/reports?ts=1721484104&sid=e11707d5-02a7-43ef-b45e-2cf4d2036f7d&s=6Kc1EgeyymsGCnxaFYx8FFjCqSjPngbLD%2Fy%2Bn7QqOow%3D"}]}
178
+ <- Reporting-Endpoints: heroku-nel=https://nel.heroku.com/reports?ts=1721484104&sid=e11707d5-02a7-43ef-b45e-2cf4d2036f7d&s=6Kc1EgeyymsGCnxaFYx8FFjCqSjPngbLD%2Fy%2Bn7QqOow%3D
179
+ <- Nel: {"report_to":"heroku-nel","max_age":3600,"success_fraction":0.005,"failure_fraction":0.05,"response_headers":["Via"]}
180
+ <- X-Powered-By: Express
181
+ <- X-Ratelimit-Limit: 1000
182
+ <- X-Ratelimit-Remaining: 997
183
+ <- X-Ratelimit-Reset: 1721484152
184
+ <- Vary: Origin, X-HTTP-Method-Override, Accept-Encoding
185
+ <- Access-Control-Allow-Credentials: true
186
+ <- Cache-Control: no-cache
187
+ <- Pragma: no-cache
188
+ <- Expires: -1
189
+ <- X-Content-Type-Options: nosniff
190
+ <- Etag: W/"2-vyGp6PvFo4RvsFtPoIWeCReyIC8"
191
+ <- Via: 1.1 vegur
192
+ <- Cf-Cache-Status: DYNAMIC
193
+ <- Server: cloudflare
194
+ <- Cf-Ray: 8a637c2298c0bab7-MXP
195
+ <- Alt-Svc: h3=":443"; ma=86400
196
+ <- Length: 2 Body: {}
197
+ I, [2024-07-20T17:01:44.523950 #38292] INFO -- : MintHttp Log (https://jsonplaceholder.typicode.com/posts)
198
+ @@ Timeouts: 5, 5, 20
199
+ @@ Time: 619606.947 -> 619607.12 connecting: 0.173 total: 0.378 seconds
200
+ @@ TLS: TLSv1.3 Cipher: TLS_AES_256_GCM_SHA384
201
+ -> POST /posts HTTP/1.1
202
+ -> Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
203
+ -> Accept: application/json
204
+ -> User-Agent: Mint Http
205
+ -> Host: jsonplaceholder.typicode.com
206
+ -> Content-Type: application/json
207
+ -> Content-Length: 13
208
+ -> {"foo":"bar"}
209
+ =======
210
+ <- Response: HTTP/1.1 201 Created
211
+ <- Date: Sat, 20 Jul 2024 14:01:44 GMT
212
+ <- Content-Type: application/json; charset=utf-8
213
+ <- Content-Length: 31
214
+ <- Connection: keep-alive
215
+ <- Report-To: {"group":"heroku-nel","max_age":3600,"endpoints":[{"url":"https://nel.heroku.com/reports?ts=1721484104&sid=e11707d5-02a7-43ef-b45e-2cf4d2036f7d&s=6Kc1EgeyymsGCnxaFYx8FFjCqSjPngbLD%2Fy%2Bn7QqOow%3D"}]}
216
+ <- Reporting-Endpoints: heroku-nel=https://nel.heroku.com/reports?ts=1721484104&sid=e11707d5-02a7-43ef-b45e-2cf4d2036f7d&s=6Kc1EgeyymsGCnxaFYx8FFjCqSjPngbLD%2Fy%2Bn7QqOow%3D
217
+ <- Nel: {"report_to":"heroku-nel","max_age":3600,"success_fraction":0.005,"failure_fraction":0.05,"response_headers":["Via"]}
218
+ <- X-Powered-By: Express
219
+ <- X-Ratelimit-Limit: 1000
220
+ <- X-Ratelimit-Remaining: 996
221
+ <- X-Ratelimit-Reset: 1721484152
222
+ <- Vary: Origin, X-HTTP-Method-Override, Accept-Encoding
223
+ <- Access-Control-Allow-Credentials: true
224
+ <- Cache-Control: no-cache
225
+ <- Pragma: no-cache
226
+ <- Expires: -1
227
+ <- Access-Control-Expose-Headers: Location
228
+ <- Location: https://jsonplaceholder.typicode.com/posts/101
229
+ <- X-Content-Type-Options: nosniff
230
+ <- Etag: W/"1f-sBekL1M+V8GEMnkCGs539pAhjpU"
231
+ <- Via: 1.1 vegur
232
+ <- Cf-Cache-Status: DYNAMIC
233
+ <- Server: cloudflare
234
+ <- Cf-Ray: 8a637c24ee9b83a2-MXP
235
+ <- Alt-Svc: h3=":443"; ma=86400
236
+ <- Length: 31 Body: {
237
+ "foo": "bar",
238
+ "id": 101
239
+ }
240
+ I, [2024-07-20T17:01:43.774717 #38292] INFO -- : MintHttp Log (https://jsonplaceholder.typicode.com/todos/1)
241
+ @@ Timeouts: 5, 5, 20
242
+ @@ Time: 619605.878 -> 619606.057 connecting: 0.179 total: 0.698 seconds
243
+ @@ TLS: TLSv1.3 Cipher: TLS_AES_256_GCM_SHA384
244
+ -> POST /todos/1 HTTP/1.1
245
+ -> Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
246
+ -> Accept: application/json
247
+ -> User-Agent: Mint Http
248
+ -> Host: jsonplaceholder.typicode.com
249
+ -> Content-Type: application/json
250
+ -> Content-Length: 13
251
+ -> {"foo":"bar"}
252
+ =======
253
+ <- Response: HTTP/1.1 404 Not Found
254
+ <- Date: Sat, 20 Jul 2024 14:01:43 GMT
255
+ <- Content-Type: application/json; charset=utf-8
256
+ <- Content-Length: 2
257
+ <- Connection: keep-alive
258
+ <- Report-To: {"group":"heroku-nel","max_age":3600,"endpoints":[{"url":"https://nel.heroku.com/reports?ts=1721484103&sid=e11707d5-02a7-43ef-b45e-2cf4d2036f7d&s=b4Wm3JpEawzMn3h85DNdBHYfHUie%2BeyhfNXaCcm4ybI%3D"}]}
259
+ <- Reporting-Endpoints: heroku-nel=https://nel.heroku.com/reports?ts=1721484103&sid=e11707d5-02a7-43ef-b45e-2cf4d2036f7d&s=b4Wm3JpEawzMn3h85DNdBHYfHUie%2BeyhfNXaCcm4ybI%3D
260
+ <- Nel: {"report_to":"heroku-nel","max_age":3600,"success_fraction":0.005,"failure_fraction":0.05,"response_headers":["Via"]}
261
+ <- X-Powered-By: Express
262
+ <- X-Ratelimit-Limit: 1000
263
+ <- X-Ratelimit-Remaining: 998
264
+ <- X-Ratelimit-Reset: 1721484152
265
+ <- Vary: Origin, X-HTTP-Method-Override, Accept-Encoding
266
+ <- Access-Control-Allow-Credentials: true
267
+ <- Cache-Control: no-cache
268
+ <- Pragma: no-cache
269
+ <- Expires: -1
270
+ <- X-Content-Type-Options: nosniff
271
+ <- Etag: W/"2-vyGp6PvFo4RvsFtPoIWeCReyIC8"
272
+ <- Via: 1.1 vegur
273
+ <- Cf-Cache-Status: DYNAMIC
274
+ <- Server: cloudflare
275
+ <- Cf-Ray: 8a637c1e4a94ba8c-MXP
276
+ <- Alt-Svc: h3=":443"; ma=86400
277
+ <- Length: 2 Body: {}
278
+ I, [2024-07-20T17:01:42.133289 #38292] INFO -- : MintHttp Log (https://example.com)
279
+ @@ Timeouts: 5, 5, 20
280
+ @@ Time: 619604.234 -> 619604.717 connecting: 0.482 total: 0.701 seconds
281
+ @@ TLS: TLSv1.3 Cipher: TLS_AES_256_GCM_SHA384
282
+ -> POST HTTP/1.1
283
+ -> Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
284
+ -> Accept: application/json
285
+ -> User-Agent: Mint Http
286
+ -> Host: example.com
287
+ -> Content-Type: application/json
288
+ -> Content-Length: 13
289
+ -> {"foo":"bar"}
290
+ =======
291
+ <- Response: HTTP/1.1 200 OK
292
+ <- Accept-Ranges: bytes
293
+ <- Cache-Control: max-age=604800
294
+ <- Content-Type: text/html; charset=UTF-8
295
+ <- Date: Sat, 20 Jul 2024 14:01:42 GMT
296
+ <- Etag: "3147526947"
297
+ <- Expires: Sat, 27 Jul 2024 14:01:42 GMT
298
+ <- Last-Modified: Thu, 17 Oct 2019 07:18:26 GMT
299
+ <- Server: EOS (vny/044F)
300
+ <- Content-Length: 1256
301
+ <- Length: 1256 Body: <!doctype html>
302
+ <html>
303
+ <head>
304
+ <title>Example Domain</title>
305
+
306
+ <meta charset="utf-8" />
307
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
308
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
309
+ <style type="text/css">
310
+ body {
311
+ background-color: #f0f0f2;
312
+ margin: 0;
313
+ padding: 0;
314
+ font-family: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
315
+
316
+ }
317
+ div {
318
+ width: 600px;
319
+ margin: 5em auto;
320
+ padding: 2em;
321
+ background-color: #fdfdff;
322
+ border-radius: 0.5em;
323
+ box-shadow: 2px 3px 7px 2px rgba(0,0,0,0.02);
324
+ }
325
+ a:link, a:visited {
326
+ color: #38488f;
327
+ text-decoration: none;
328
+ }
329
+ @media (max-width: 700px) {
330
+ div {
331
+ margin: 0 auto;
332
+ width: auto;
333
+ }
334
+ }
335
+ </style>
336
+ </head>
337
+
338
+ <body>
339
+ <div>
340
+ <h1>Example Domain</h1>
341
+ <p>This domain is for use in illustrative examples in documents. You may use this
342
+ domain in literature without prior coordination or asking for permission.</p>
343
+ <p><a href="https://www.iana.org/domains/example">More information...</a></p>
344
+ </div>
345
+ </body>
346
+ </html>
347
+ I, [2024-07-20T17:03:13.605159 #38509] INFO -- : MintHttp Log (https://dashboard.moyasar.com)
348
+ @@ Timeouts: 5, 5, 20
349
+ @@ Time: 619696.021 -> 619696.301 connecting: 0.28 total: 0.385 seconds
350
+ @@ TLS: TLSv1.3 Cipher: TLS_AES_128_GCM_SHA256
351
+ -> POST HTTP/1.1
352
+ -> Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
353
+ -> Accept: application/json
354
+ -> User-Agent: Mint Http
355
+ -> Host: dashboard.moyasar.com
356
+ -> Content-Type: application/json
357
+ -> Content-Length: 13
358
+ -> {"foo":"bar"}
359
+ =======
360
+ <- Response: HTTP/1.1 500 Internal Server Error
361
+ <- Date: Sat, 20 Jul 2024 14:03:13 GMT
362
+ <- Content-Type: text/plain; charset=utf-8
363
+ <- Transfer-Encoding: chunked
364
+ <- Connection: keep-alive
365
+ <- X-Request-Id: b83bb0ba-f745-432f-bea8-37ab094afc3d
366
+ <- X-Runtime: 0.003190
367
+ <- Vary: Accept-Encoding
368
+ <- Strict-Transport-Security: max-age=63072000; includeSubDomains
369
+ <- Length: 182 Body: 500 Internal Server Error
370
+ If you are the administrator of this website, then please read this web application's log file and/or the web server's log file to find out what went wrong.
371
+ I, [2024-07-20T17:03:12.774798 #38509] INFO -- : MintHttp Log (https://api.moyasar.com)
372
+ @@ Timeouts: 5, 5, 20
373
+ @@ Time: 619695.17 -> 619695.469 connecting: 0.299 total: 0.406 seconds
374
+ @@ TLS: TLSv1.2 Cipher: ECDHE-RSA-AES128-GCM-SHA256
375
+ -> POST HTTP/1.1
376
+ -> Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
377
+ -> Accept: application/json
378
+ -> User-Agent: Mint Http
379
+ -> Host: api.moyasar.com
380
+ -> Content-Type: application/json
381
+ -> Content-Length: 13
382
+ -> {"foo":"bar"}
383
+ =======
384
+ <- Response: HTTP/1.1 404 Not Found
385
+ <- Date: Sat, 20 Jul 2024 14:03:12 GMT
386
+ <- Content-Type: application/json; charset=utf-8
387
+ <- Content-Length: 91
388
+ <- Connection: keep-alive
389
+ <- X-Frame-Options: SAMEORIGIN
390
+ <- X-Xss-Protection: 0
391
+ <- X-Content-Type-Options: nosniff
392
+ <- X-Download-Options: noopen
393
+ <- X-Permitted-Cross-Domain-Policies: none
394
+ <- Referrer-Policy: strict-origin-when-cross-origin
395
+ <- X-Request-Id: 84cd8953-824a-4906-82ee-1a980d613dcf
396
+ <- X-Runtime: 0.005813
397
+ <- Strict-Transport-Security: max-age=63072000; includeSubDomains
398
+ <- Vary: Origin
399
+ <- Length: 91 Body: {
400
+ "type": "invalid_request_error",
401
+ "message": "Resource not found",
402
+ "errors": null
403
+ }
404
+ I, [2024-07-20T17:03:16.172324 #38509] INFO -- : MintHttp Log (https://ipinfo.com/1.1.1.1)
405
+ @@ Timeouts: 5, 5, 20
406
+ @@ Time: 619697.104 -> 619698.655 connecting: 1.551 total: 1.87 seconds
407
+ @@ TLS: TLSv1.3 Cipher: TLS_AES_256_GCM_SHA384
408
+ -> POST /1.1.1.1 HTTP/1.1
409
+ -> Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
410
+ -> Accept: application/json
411
+ -> User-Agent: Mint Http
412
+ -> Host: ipinfo.com
413
+ -> Content-Type: application/json
414
+ -> Content-Length: 13
415
+ -> {"foo":"bar"}
416
+ =======
417
+ <- Response: HTTP/1.1 404 Not Found
418
+ <- Date: Sat, 20 Jul 2024 14:03:16 GMT
419
+ <- Server: Apache
420
+ <- Content-Length: 315
421
+ <- Content-Type: text/html; charset=iso-8859-1
422
+ <- Length: 315 Body: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
423
+ <html><head>
424
+ <title>404 Not Found</title>
425
+ </head><body>
426
+ <h1>Not Found</h1>
427
+ <p>The requested URL was not found on this server.</p>
428
+ <p>Additionally, a 404 Not Found
429
+ error was encountered while trying to use an ErrorDocument to handle the request.</p>
430
+ </body></html>
431
+ I, [2024-07-20T17:03:16.760845 #38509] INFO -- : MintHttp Log (https://jsonplaceholder.typicode.com/todos)
432
+ @@ Timeouts: 5, 5, 20
433
+ @@ Time: 619698.974 -> 619699.16 connecting: 0.186 total: 0.588 seconds
434
+ @@ TLS: TLSv1.3 Cipher: TLS_AES_256_GCM_SHA384
435
+ -> POST /todos HTTP/1.1
436
+ -> Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
437
+ -> Accept: application/json
438
+ -> User-Agent: Mint Http
439
+ -> Host: jsonplaceholder.typicode.com
440
+ -> Content-Type: application/json
441
+ -> Content-Length: 13
442
+ -> {"foo":"bar"}
443
+ =======
444
+ <- Response: HTTP/1.1 201 Created
445
+ <- Date: Sat, 20 Jul 2024 14:03:16 GMT
446
+ <- Content-Type: application/json; charset=utf-8
447
+ <- Content-Length: 31
448
+ <- Connection: keep-alive
449
+ <- Report-To: {"group":"heroku-nel","max_age":3600,"endpoints":[{"url":"https://nel.heroku.com/reports?ts=1721484196&sid=e11707d5-02a7-43ef-b45e-2cf4d2036f7d&s=tM%2FBbHTq57%2BsNunb7rnddrY6QyUOMANVCb6RtLjfM1g%3D"}]}
450
+ <- Reporting-Endpoints: heroku-nel=https://nel.heroku.com/reports?ts=1721484196&sid=e11707d5-02a7-43ef-b45e-2cf4d2036f7d&s=tM%2FBbHTq57%2BsNunb7rnddrY6QyUOMANVCb6RtLjfM1g%3D
451
+ <- Nel: {"report_to":"heroku-nel","max_age":3600,"success_fraction":0.005,"failure_fraction":0.05,"response_headers":["Via"]}
452
+ <- X-Powered-By: Express
453
+ <- X-Ratelimit-Limit: 1000
454
+ <- X-Ratelimit-Remaining: 999
455
+ <- X-Ratelimit-Reset: 1721484212
456
+ <- Vary: Origin, X-HTTP-Method-Override, Accept-Encoding
457
+ <- Access-Control-Allow-Credentials: true
458
+ <- Cache-Control: no-cache
459
+ <- Pragma: no-cache
460
+ <- Expires: -1
461
+ <- Access-Control-Expose-Headers: Location
462
+ <- Location: https://jsonplaceholder.typicode.com/todos/201
463
+ <- X-Content-Type-Options: nosniff
464
+ <- Etag: W/"1f-v7q09ihdcrnA2mAxihAAQHEaYaQ"
465
+ <- Via: 1.1 vegur
466
+ <- Cf-Cache-Status: DYNAMIC
467
+ <- Server: cloudflare
468
+ <- Cf-Ray: 8a637e642d124c46-MXP
469
+ <- Alt-Svc: h3=":443"; ma=86400
470
+ <- Length: 31 Body: {
471
+ "foo": "bar",
472
+ "id": 201
473
+ }
474
+ I, [2024-07-20T17:03:13.218866 #38509] INFO -- : MintHttp Log (https://api.moyasar.com/v1/payments)
475
+ @@ Timeouts: 5, 5, 20
476
+ @@ Time: 619695.592 -> 619695.914 connecting: 0.322 total: 0.428 seconds
477
+ @@ TLS: TLSv1.2 Cipher: ECDHE-RSA-AES128-GCM-SHA256
478
+ -> POST /v1/payments HTTP/1.1
479
+ -> Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
480
+ -> Accept: application/json
481
+ -> User-Agent: Mint Http
482
+ -> Host: api.moyasar.com
483
+ -> Content-Type: application/json
484
+ -> Content-Length: 13
485
+ -> {"foo":"bar"}
486
+ =======
487
+ <- Response: HTTP/1.1 401 Unauthorized
488
+ <- Date: Sat, 20 Jul 2024 14:03:13 GMT
489
+ <- Content-Type: application/json; charset=utf-8
490
+ <- Content-Length: 91
491
+ <- Connection: keep-alive
492
+ <- X-Frame-Options: SAMEORIGIN
493
+ <- X-Xss-Protection: 0
494
+ <- X-Content-Type-Options: nosniff
495
+ <- X-Download-Options: noopen
496
+ <- X-Permitted-Cross-Domain-Policies: none
497
+ <- Referrer-Policy: strict-origin-when-cross-origin
498
+ <- Www-Authenticate: Basic realm="Application"
499
+ <- Cache-Control: no-cache
500
+ <- X-Request-Id: 77826288-0720-4b84-9c86-0079a2f79ab3
501
+ <- X-Runtime: 0.004735
502
+ <- Strict-Transport-Security: max-age=63072000; includeSubDomains
503
+ <- Vary: Origin
504
+ <- Length: 91 Body: {"type":"authentication_error","message":"Invalid authorization credentials","errors":null}
505
+ I, [2024-07-20T17:03:17.220251 #38509] INFO -- : MintHttp Log (https://jsonplaceholder.typicode.com/todos/1)
506
+ @@ Timeouts: 5, 5, 20
507
+ @@ Time: 619699.563 -> 619699.731 connecting: 0.169 total: 0.459 seconds
508
+ @@ TLS: TLSv1.3 Cipher: TLS_AES_256_GCM_SHA384
509
+ -> POST /todos/1 HTTP/1.1
510
+ -> Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
511
+ -> Accept: application/json
512
+ -> User-Agent: Mint Http
513
+ -> Host: jsonplaceholder.typicode.com
514
+ -> Content-Type: application/json
515
+ -> Content-Length: 13
516
+ -> {"foo":"bar"}
517
+ =======
518
+ <- Response: HTTP/1.1 404 Not Found
519
+ <- Date: Sat, 20 Jul 2024 14:03:17 GMT
520
+ <- Content-Type: application/json; charset=utf-8
521
+ <- Content-Length: 2
522
+ <- Connection: keep-alive
523
+ <- Report-To: {"group":"heroku-nel","max_age":3600,"endpoints":[{"url":"https://nel.heroku.com/reports?ts=1721484197&sid=e11707d5-02a7-43ef-b45e-2cf4d2036f7d&s=Jk6%2B0Z%2FbwSrMcljiDfaEWMOCwl2BpuLPEFla3gach%2B8%3D"}]}
524
+ <- Reporting-Endpoints: heroku-nel=https://nel.heroku.com/reports?ts=1721484197&sid=e11707d5-02a7-43ef-b45e-2cf4d2036f7d&s=Jk6%2B0Z%2FbwSrMcljiDfaEWMOCwl2BpuLPEFla3gach%2B8%3D
525
+ <- Nel: {"report_to":"heroku-nel","max_age":3600,"success_fraction":0.005,"failure_fraction":0.05,"response_headers":["Via"]}
526
+ <- X-Powered-By: Express
527
+ <- X-Ratelimit-Limit: 1000
528
+ <- X-Ratelimit-Remaining: 998
529
+ <- X-Ratelimit-Reset: 1721484212
530
+ <- Vary: Origin, X-HTTP-Method-Override, Accept-Encoding
531
+ <- Access-Control-Allow-Credentials: true
532
+ <- Cache-Control: no-cache
533
+ <- Pragma: no-cache
534
+ <- Expires: -1
535
+ <- X-Content-Type-Options: nosniff
536
+ <- Etag: W/"2-vyGp6PvFo4RvsFtPoIWeCReyIC8"
537
+ <- Via: 1.1 vegur
538
+ <- Cf-Cache-Status: DYNAMIC
539
+ <- Server: cloudflare
540
+ <- Cf-Ray: 8a637e67bd835a43-MXP
541
+ <- Alt-Svc: h3=":443"; ma=86400
542
+ <- Length: 2 Body: {}
543
+ I, [2024-07-20T17:03:14.301120 #38509] INFO -- : MintHttp Log (https://example.com)
544
+ @@ Timeouts: 5, 5, 20
545
+ @@ Time: 619696.408 -> 619696.884 connecting: 0.476 total: 0.695 seconds
546
+ @@ TLS: TLSv1.3 Cipher: TLS_AES_256_GCM_SHA384
547
+ -> POST HTTP/1.1
548
+ -> Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
549
+ -> Accept: application/json
550
+ -> User-Agent: Mint Http
551
+ -> Host: example.com
552
+ -> Content-Type: application/json
553
+ -> Content-Length: 13
554
+ -> {"foo":"bar"}
555
+ =======
556
+ <- Response: HTTP/1.1 200 OK
557
+ <- Accept-Ranges: bytes
558
+ <- Cache-Control: max-age=604800
559
+ <- Content-Type: text/html; charset=UTF-8
560
+ <- Date: Sat, 20 Jul 2024 14:03:14 GMT
561
+ <- Etag: "3147526947"
562
+ <- Expires: Sat, 27 Jul 2024 14:03:14 GMT
563
+ <- Last-Modified: Thu, 17 Oct 2019 07:18:26 GMT
564
+ <- Server: EOS (vny/044F)
565
+ <- Content-Length: 1256
566
+ <- Length: 1256 Body: <!doctype html>
567
+ <html>
568
+ <head>
569
+ <title>Example Domain</title>
570
+
571
+ <meta charset="utf-8" />
572
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
573
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
574
+ <style type="text/css">
575
+ body {
576
+ background-color: #f0f0f2;
577
+ margin: 0;
578
+ padding: 0;
579
+ font-family: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
580
+
581
+ }
582
+ div {
583
+ width: 600px;
584
+ margin: 5em auto;
585
+ padding: 2em;
586
+ background-color: #fdfdff;
587
+ border-radius: 0.5em;
588
+ box-shadow: 2px 3px 7px 2px rgba(0,0,0,0.02);
589
+ }
590
+ a:link, a:visited {
591
+ color: #38488f;
592
+ text-decoration: none;
593
+ }
594
+ @media (max-width: 700px) {
595
+ div {
596
+ margin: 0 auto;
597
+ width: auto;
598
+ }
599
+ }
600
+ </style>
601
+ </head>
602
+
603
+ <body>
604
+ <div>
605
+ <h1>Example Domain</h1>
606
+ <p>This domain is for use in illustrative examples in documents. You may use this
607
+ domain in literature without prior coordination or asking for permission.</p>
608
+ <p><a href="https://www.iana.org/domains/example">More information...</a></p>
609
+ </div>
610
+ </body>
611
+ </html>
612
+ I, [2024-07-20T17:03:17.748015 #38509] INFO -- : MintHttp Log (https://jsonplaceholder.typicode.com/posts/1)
613
+ @@ Timeouts: 5, 5, 20
614
+ @@ Time: 619700.023 -> 619700.2 connecting: 0.177 total: 0.526 seconds
615
+ @@ TLS: TLSv1.3 Cipher: TLS_AES_256_GCM_SHA384
616
+ -> POST /posts/1 HTTP/1.1
617
+ -> Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
618
+ -> Accept: application/json
619
+ -> User-Agent: Mint Http
620
+ -> Host: jsonplaceholder.typicode.com
621
+ -> Content-Type: application/json
622
+ -> Content-Length: 13
623
+ -> {"foo":"bar"}
624
+ =======
625
+ <- Response: HTTP/1.1 404 Not Found
626
+ <- Date: Sat, 20 Jul 2024 14:03:17 GMT
627
+ <- Content-Type: application/json; charset=utf-8
628
+ <- Content-Length: 2
629
+ <- Connection: keep-alive
630
+ <- Report-To: {"group":"heroku-nel","max_age":3600,"endpoints":[{"url":"https://nel.heroku.com/reports?ts=1721484197&sid=e11707d5-02a7-43ef-b45e-2cf4d2036f7d&s=Jk6%2B0Z%2FbwSrMcljiDfaEWMOCwl2BpuLPEFla3gach%2B8%3D"}]}
631
+ <- Reporting-Endpoints: heroku-nel=https://nel.heroku.com/reports?ts=1721484197&sid=e11707d5-02a7-43ef-b45e-2cf4d2036f7d&s=Jk6%2B0Z%2FbwSrMcljiDfaEWMOCwl2BpuLPEFla3gach%2B8%3D
632
+ <- Nel: {"report_to":"heroku-nel","max_age":3600,"success_fraction":0.005,"failure_fraction":0.05,"response_headers":["Via"]}
633
+ <- X-Powered-By: Express
634
+ <- X-Ratelimit-Limit: 1000
635
+ <- X-Ratelimit-Remaining: 997
636
+ <- X-Ratelimit-Reset: 1721484212
637
+ <- Vary: Origin, X-HTTP-Method-Override, Accept-Encoding
638
+ <- Access-Control-Allow-Credentials: true
639
+ <- Cache-Control: no-cache
640
+ <- Pragma: no-cache
641
+ <- Expires: -1
642
+ <- X-Content-Type-Options: nosniff
643
+ <- Etag: W/"2-vyGp6PvFo4RvsFtPoIWeCReyIC8"
644
+ <- Via: 1.1 vegur
645
+ <- Cf-Cache-Status: DYNAMIC
646
+ <- Server: cloudflare
647
+ <- Cf-Ray: 8a637e6aaac20d64-MXP
648
+ <- Alt-Svc: h3=":443"; ma=86400
649
+ <- Length: 2 Body: {}
650
+ I, [2024-07-20T17:03:18.272730 #38509] INFO -- : MintHttp Log (https://jsonplaceholder.typicode.com/posts)
651
+ @@ Timeouts: 5, 5, 20
652
+ @@ Time: 619700.551 -> 619700.725 connecting: 0.174 total: 0.523 seconds
653
+ @@ TLS: TLSv1.3 Cipher: TLS_AES_256_GCM_SHA384
654
+ -> POST /posts HTTP/1.1
655
+ -> Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
656
+ -> Accept: application/json
657
+ -> User-Agent: Mint Http
658
+ -> Host: jsonplaceholder.typicode.com
659
+ -> Content-Type: application/json
660
+ -> Content-Length: 13
661
+ -> {"foo":"bar"}
662
+ =======
663
+ <- Response: HTTP/1.1 201 Created
664
+ <- Date: Sat, 20 Jul 2024 14:03:18 GMT
665
+ <- Content-Type: application/json; charset=utf-8
666
+ <- Content-Length: 31
667
+ <- Connection: keep-alive
668
+ <- Report-To: {"group":"heroku-nel","max_age":3600,"endpoints":[{"url":"https://nel.heroku.com/reports?ts=1721484198&sid=e11707d5-02a7-43ef-b45e-2cf4d2036f7d&s=dBxS26JOHwx7%2BNDSjKkei5MCYIR0VkgOLm9jUXNq4ZU%3D"}]}
669
+ <- Reporting-Endpoints: heroku-nel=https://nel.heroku.com/reports?ts=1721484198&sid=e11707d5-02a7-43ef-b45e-2cf4d2036f7d&s=dBxS26JOHwx7%2BNDSjKkei5MCYIR0VkgOLm9jUXNq4ZU%3D
670
+ <- Nel: {"report_to":"heroku-nel","max_age":3600,"success_fraction":0.005,"failure_fraction":0.05,"response_headers":["Via"]}
671
+ <- X-Powered-By: Express
672
+ <- X-Ratelimit-Limit: 1000
673
+ <- X-Ratelimit-Remaining: 996
674
+ <- X-Ratelimit-Reset: 1721484212
675
+ <- Vary: Origin, X-HTTP-Method-Override, Accept-Encoding
676
+ <- Access-Control-Allow-Credentials: true
677
+ <- Cache-Control: no-cache
678
+ <- Pragma: no-cache
679
+ <- Expires: -1
680
+ <- Access-Control-Expose-Headers: Location
681
+ <- Location: https://jsonplaceholder.typicode.com/posts/101
682
+ <- X-Content-Type-Options: nosniff
683
+ <- Etag: W/"1f-sBekL1M+V8GEMnkCGs539pAhjpU"
684
+ <- Via: 1.1 vegur
685
+ <- Cf-Cache-Status: DYNAMIC
686
+ <- Server: cloudflare
687
+ <- Cf-Ray: 8a637e6dff40bafd-MXP
688
+ <- Alt-Svc: h3=":443"; ma=86400
689
+ <- Length: 31 Body: {
690
+ "foo": "bar",
691
+ "id": 101
692
+ }
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Net
4
+ class HTTP
5
+ def buffered_socket
6
+ @socket
7
+ end
8
+
9
+ def underlying_tcp_socket
10
+ socket = @socket&.io
11
+
12
+ if socket.is_a?(OpenSSL::SSL::SSLSocket)
13
+ socket = socket.io
14
+ end
15
+
16
+ socket
17
+ end
18
+ end
19
+ end
@@ -67,7 +67,11 @@ class MintHttp::NetHttpFactory
67
67
  net_http.verify_hostname = options[:verify_hostname]
68
68
  net_http.min_version = options[:min_version]
69
69
  net_http.max_version = options[:max_version]
70
-
70
+
71
+ # Keep-alive Options
72
+ # Keep-alive timeout is made 1 month to allow maximum connection time
73
+ # since persistent connection management is handled by MintHttp::Pool
74
+ net_http.keep_alive_timeout = 2_592_000
71
75
 
72
76
  if OpenSSL::X509::Store === options[:ca]
73
77
  net_http.cert_store = options[:ca]
@@ -6,6 +6,7 @@ class MintHttp::Pool
6
6
  attr_reader :timeout
7
7
  attr_reader :size
8
8
  attr_reader :usage_limit
9
+ attr_reader :created_connections
9
10
 
10
11
  def initialize(options = {})
11
12
  @mutex = Mutex.new
@@ -16,6 +17,7 @@ class MintHttp::Pool
16
17
 
17
18
  @size = options[:size] || 10
18
19
  @usage_limit = options[:usage_limit] || 100
20
+ @created_connections = 0
19
21
 
20
22
  @pool = []
21
23
  end
@@ -43,6 +45,9 @@ class MintHttp::Pool
43
45
  client = net_factory.make_client(hostname, port, options)
44
46
  entry = append(client, namespace)
45
47
  entry.acquire!
48
+
49
+ @created_connections += 1
50
+
46
51
  return entry.client
47
52
  end
48
53
  end
@@ -69,6 +74,10 @@ class MintHttp::Pool
69
74
  end
70
75
  end
71
76
 
77
+ def current_size
78
+ @mutex.synchronize { @pool.length }
79
+ end
80
+
72
81
  private
73
82
 
74
83
  def append(client, namespace)
@@ -16,7 +16,6 @@ class MintHttp::PoolEntry
16
16
  @birth_time = time_ms
17
17
  @last_used = time_ms
18
18
  @usage = 0
19
- @unhealthy = false
20
19
  end
21
20
 
22
21
  def matches?(other)
@@ -50,18 +49,20 @@ class MintHttp::PoolEntry
50
49
  end
51
50
 
52
51
  def available?
53
- !@acquired && !expired? && !@unhealthy
52
+ !@acquired && !expired? && healthy?
54
53
  end
55
54
 
56
55
  def healthy?
57
- # TODO: add health check
58
- healthy = true
59
- @unhealthy = !healthy
60
- healthy
56
+ socket = client.underlying_tcp_socket
57
+ unless socket
58
+ return false
59
+ end
60
+
61
+ !socket.closed? && !(socket.wait_readable(0) && client.buffered_socket.eof?)
61
62
  end
62
63
 
63
64
  def to_clean?
64
- (expired? || @unhealthy) && !@acquired
65
+ (expired? || !healthy?) && !@acquired
65
66
  end
66
67
 
67
68
  private
@@ -283,10 +283,12 @@ module MintHttp
283
283
  logger.log_start
284
284
 
285
285
  begin
286
- res = with_client(url.hostname, url.port, options) do |http|
286
+ response = with_client(url.hostname, url.port, options) do |http|
287
287
  logger.log_connected
288
288
  logger.log_connection_info(http)
289
- http.request(net_request)
289
+ net_response = http.request(net_request)
290
+
291
+ Response.new(net_response, net_request, self, http)
290
292
  end
291
293
  rescue StandardError => error
292
294
  logger.log_end
@@ -297,9 +299,6 @@ module MintHttp
297
299
  end
298
300
 
299
301
  logger.log_end
300
-
301
- response = Response.new(res, net_request, self)
302
-
303
302
  logger.log_response(response)
304
303
  logger.put_timing(response)
305
304
  logger.write_log
@@ -30,16 +30,39 @@ module MintHttp
30
30
  # @return [Hash<String,Array[String]>]
31
31
  attr_reader :headers
32
32
 
33
+ # @!attribute [r] time_started
34
+ # @return [Numeric]
33
35
  attr_accessor :time_started
36
+
37
+ # @!attribute [r] time_ended
38
+ # @return [Numeric]
34
39
  attr_accessor :time_ended
40
+
41
+ # @!attribute [r] time_connected
42
+ # @return [Numeric]
35
43
  attr_accessor :time_connected
44
+
45
+ # @!attribute [r] time_total
46
+ # @return [Numeric]
36
47
  attr_accessor :time_total
48
+
49
+ # @!attribute [r] time_connecting
50
+ # @return [Numeric]
37
51
  attr_accessor :time_connecting
38
52
 
53
+ # @!attribute [r] local_address
54
+ # @return [Addrinfo]
55
+ attr_reader :local_address
56
+
57
+ # @!attribute [r] remote_address
58
+ # @return [Addrinfo]
59
+ attr_reader :remote_address
60
+
39
61
  # @param [Net::HTTPResponse] net_response
40
62
  # @param [Net::HTTPRequest] net_request
41
63
  # @param [MintHttp::Request] mint_request
42
- def initialize(net_response, net_request, mint_request)
64
+ # @param [Net::HTTP]
65
+ def initialize(net_response, net_request, mint_request, net_http)
43
66
  @net_response = net_response
44
67
  @net_request = net_request
45
68
  @mint_request = mint_request
@@ -47,6 +70,10 @@ module MintHttp
47
70
  @status_code = net_response.code.to_i
48
71
  @status_text = net_response.message
49
72
  @headers = Headers.new.merge(net_response.each_header.to_h)
73
+
74
+ tcp_socket = net_http.underlying_tcp_socket
75
+ @local_address = tcp_socket.local_address rescue nil
76
+ @remote_address = tcp_socket.remote_address rescue nil
50
77
  end
51
78
 
52
79
  def success?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MintHttp
4
- VERSION = "1.0.1"
4
+ VERSION = "1.1.0"
5
5
  end
data/lib/mint_http.rb CHANGED
@@ -12,6 +12,7 @@ require_relative 'mint_http/net_http_factory'
12
12
  require_relative 'mint_http/request_logger'
13
13
  require_relative 'mint_http/response'
14
14
  require_relative 'mint_http/request'
15
+ require_relative 'mint_http/net_http'
15
16
 
16
17
  module MintHttp
17
18
  class << self
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: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ali Alhoshaiyan
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-05-26 00:00:00.000000000 Z
11
+ date: 2025-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-http
@@ -108,10 +108,12 @@ files:
108
108
  - LICENSE.txt
109
109
  - README.md
110
110
  - Rakefile
111
+ - http.log
111
112
  - lib/mint_http.rb
112
113
  - lib/mint_http/config.rb
113
114
  - lib/mint_http/errors.rb
114
115
  - lib/mint_http/headers.rb
116
+ - lib/mint_http/net_http.rb
115
117
  - lib/mint_http/net_http_factory.rb
116
118
  - lib/mint_http/pool.rb
117
119
  - lib/mint_http/pool_entry.rb