philiprehberger-http_client 0.8.2 → 0.9.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 +5 -0
- data/README.md +1 -0
- data/lib/philiprehberger/http_client/response.rb +14 -0
- data/lib/philiprehberger/http_client/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1e63a67f4b54b15483e76030335e46423d1845a22a33d6e72aa07e984455c7f6
|
|
4
|
+
data.tar.gz: ba12ae4825bfde2e9e8e4e0a968a8bf96faaf368b83c17d87713064b8cbf8243
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5c184d72bd21f7ba81f5a26ec9a06405c822ee8ff447c8ce842255dc872a06311465c41a9a2f71f539860c26131f30dec10bd9e07e98bb61471b1524367e01a8
|
|
7
|
+
data.tar.gz: ae802ee7c9d369673bf9c3ea28d8c1230fa3071755b7e82d2b92d7396d9a539e7e19bd623d96596d3bb2b1d1c2416e5ae4737e2b5aa449cc6906179e68e8bff6
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,11 @@ and this gem adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.9.0] - 2026-04-20
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- `Response#json?` — returns `true` when the `Content-Type` header advertises JSON, including RFC 6838 `+json` structured-syntax suffixes (e.g. `application/problem+json`). Case-insensitive header lookup; charset parameters are ignored.
|
|
14
|
+
|
|
10
15
|
## [0.8.2] - 2026-04-16
|
|
11
16
|
|
|
12
17
|
### Added
|
data/README.md
CHANGED
|
@@ -493,6 +493,7 @@ client.head("/resource")
|
|
|
493
493
|
| `headers` | Hash | Response headers |
|
|
494
494
|
| `ok?` | Boolean | `true` if status is 200-299 |
|
|
495
495
|
| `json` | Hash | Parsed JSON body |
|
|
496
|
+
| `json?` | Boolean | `true` if `Content-Type` is `application/json` or `+json` suffix |
|
|
496
497
|
| `streaming?` | Boolean | `true` if response was streamed |
|
|
497
498
|
| `metrics` | Metrics | Request timing breakdown (total_time, first_byte_time, etc.) |
|
|
498
499
|
| `redirects` | Array | Redirect chain URLs (empty if no redirects) |
|
|
@@ -44,6 +44,20 @@ module Philiprehberger
|
|
|
44
44
|
@json ||= JSON.parse(body)
|
|
45
45
|
end
|
|
46
46
|
|
|
47
|
+
# Returns true if the `Content-Type` response header advertises JSON.
|
|
48
|
+
# Matches `application/json`, `application/problem+json`, and any
|
|
49
|
+
# other `+json` structured-syntax suffix defined by RFC 6838.
|
|
50
|
+
# Header lookup is case-insensitive.
|
|
51
|
+
#
|
|
52
|
+
# @return [Boolean]
|
|
53
|
+
def json?
|
|
54
|
+
header = headers.find { |k, _| k.to_s.downcase == 'content-type' }
|
|
55
|
+
return false unless header
|
|
56
|
+
|
|
57
|
+
value = header[1].to_s.downcase.split(';').first.to_s.strip
|
|
58
|
+
value == 'application/json' || value.end_with?('+json')
|
|
59
|
+
end
|
|
60
|
+
|
|
47
61
|
# Returns request timing metrics (nil if not available).
|
|
48
62
|
#
|
|
49
63
|
# @return [Metrics, nil]
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: philiprehberger-http_client
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.9.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Philip Rehberger
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-04-
|
|
11
|
+
date: 2026-04-20 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: A zero-dependency HTTP client built on Ruby's net/http with automatic
|
|
14
14
|
retries, request/response interceptors, and a clean API for JSON services.
|