fast-proxy-status 0.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.
@@ -0,0 +1,96 @@
1
+ # frozen_string_literal: true
2
+
3
+ # The substrate: RFC 9209's Proxy-Status is an RFC 9651 List, so this
4
+ # gem is a fast-sfv consumer, never a parser of its own.
5
+ require "fast/sfv"
6
+
7
+ require_relative "proxy_status/version"
8
+ require_relative "proxy_status/errors"
9
+ require_relative "proxy_status/registry"
10
+ require_relative "proxy_status/list_field"
11
+ require_relative "proxy_status/hop"
12
+ require_relative "proxy_status/status"
13
+ require_relative "proxy_status/cache_status"
14
+ require_relative "proxy_status/targeted_cache_control"
15
+
16
+ module Fast
17
+ # RFC 9209 Proxy-Status: the HTTP response field that conveys how
18
+ # intermediaries handled a response. "Its value is a List (see
19
+ # Section 3.1 of [STRUCTURED-FIELDS]). Each member of the List
20
+ # represents an intermediary that has handled the response. The first
21
+ # member represents the intermediary closest to the origin server, and
22
+ # the last member represents the intermediary closest to the user
23
+ # agent" (§2) — and "Each member of the List ... MUST have a type of
24
+ # either String or Token", carrying §2.1's parameters. The class is
25
+ # the field type; Error, ParseError, SerializeError, the ERRORS
26
+ # registry, Hop and Promotion nest inside it.
27
+ #
28
+ # parse is the recipient's view and never raises on field content,
29
+ # with the diagnostic leniency §2.1 demands: a field whose syntax is
30
+ # not a Structured Field Value, or whose List carries any member that
31
+ # is not a String or Token, is the ENTIRE field ignored (RFC 9651
32
+ # §2.2 — §2 defines no other handling for members), answering the
33
+ # shared frozen empty value, the same answer an absent field gives;
34
+ # while parameters NEVER fail the field — unknown parameters and
35
+ # known parameters of a type §2.1 does not allow are preserved in the
36
+ # Hop's data and ignored semantically (§2.1: "Unrecognised parameters
37
+ # MUST be ignored"; §2.1.5's own quoted-string error example parses,
38
+ # its error a String). The lenient parse is the strict walk with the
39
+ # parameter checks not applied — never the strict walk rescued — so
40
+ # the two policies cannot drift. A String is one field value; an
41
+ # Array is the field's lines, combined with ", " (RFC 9651 §4.2) — a
42
+ # List has no last-wins, the members concatenate. A wrong input type
43
+ # is a caller bug and raises TypeError.
44
+ #
45
+ # parse! is strict truth: the List failure wrapped with its message
46
+ # and byte offset, then §2's member constraint and the five §2.1
47
+ # parameter constraints, the first offender in List order raised
48
+ # positioned — the member's identifier offset, the parameter's VALUE
49
+ # offset (just past the "="; the key's end for the valueless form).
50
+ # The positioning Scan runs only on that error path. valid? answers
51
+ # the same question with a boolean and never raises.
52
+ #
53
+ # The answer is a frozen value object: hops (the Hop members in wire
54
+ # order), first/last naming §2's two ends, the typed readers on each
55
+ # Hop (error, next_hop, next_protocol, received_status, details — nil
56
+ # when the parameter is absent or wrong-typed) beside the raw #[]
57
+ # and #params, the canonical to_s ("" when nothing is held), and
58
+ # class-checked canonical equality. to_s and construction are ALWAYS
59
+ # strict, in every family gem: a sender never puts garbage on the
60
+ # wire — the identifier is a plain String (emits quoted) or a
61
+ # Fast::SFV::Token (emits bare), the class the wire-type tag; the
62
+ # five §2.1 parameters carry their sections' types.
63
+ #
64
+ # Two operations sit on the value: append (§2's append-yourself —
65
+ # "intermediaries SHOULD preserve the existing members of the field"
66
+ # — the received members in order, this intermediary's member
67
+ # appended as the LAST, a new frozen value) and promote (§2's
68
+ # trailer-promotion algorithm, spec-exact: the leftmost header
69
+ # member matching each trailer member by value characters across the
70
+ # String and Token forms, parameters ignored, replaced in its
71
+ # entirety, the trailer removed when nothing remains — answering a
72
+ # frozen Promotion).
73
+ #
74
+ # The registry is Fast::ProxyStatus::ERRORS — §2.3's 32 proxy error
75
+ # types pinned as frozen data in document order, each with its
76
+ # recommended HTTP status code (an Integer, or the RFC's own prose
77
+ # for http_request_error and proxy_internal_response), its
78
+ # response-only flag and its extra parameters, with
79
+ # registered?/recommended_status/response_only?/extra_parameters
80
+ # answering unknown names with nil/false. The registry NEVER gates a
81
+ # parse or an emit: an unknown error type parses, emits and
82
+ # round-trips untouched — future registrations never break old gem
83
+ # versions.
84
+ #
85
+ # This class is one of the gem's three field classes, and the root
86
+ # the other two descend from: Fast::CacheStatus (RFC 9211) includes
87
+ # the shared Fast::ProxyStatus::ListField engine this class was
88
+ # refactored onto — the List machinery both fields spell, extracted
89
+ # with every offset pin and allocation ceiling of this class's own
90
+ # behavior held — and Fast::TargetedCacheControl (RFC 9213) is a
91
+ # Dictionary field beside it, on the family's Dictionary shape. Each
92
+ # nests its own error hierarchy and descends from Fast::ProxyStatus::
93
+ # Error, so one rescue guards the whole gem.
94
+ class ProxyStatus
95
+ end
96
+ end
metadata ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fast-proxy-status
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Eric Jacobs
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: fast-sfv
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: '0'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: '0'
26
+ description: |
27
+ The diagnostics gem of the family, three frozen value-object
28
+ classes over fast-sfv. Fast::ProxyStatus implements RFC 9209
29
+ Proxy-Status — the HTTP response field as a List of parameterized
30
+ members, one per intermediary that handled the response, the first
31
+ closest to the origin server, with the five section 2.1 parameters
32
+ as typed readers, the diagnostic leniency of RFC 9651 2.2 (a
33
+ malformed field is treated as absent; unknown and wrong-typed
34
+ parameters are preserved in the data and ignored semantically), the
35
+ append-yourself operation, the section 2 trailer-promotion
36
+ algorithm and the 32-entry section 2.3 proxy error type registry as
37
+ frozen data with unknown passthrough. Fast::CacheStatus implements
38
+ RFC 9211 Cache-Status — the same List shape, one member per cache
39
+ that handled the request, with the eight section 2.1-2.8 parameters
40
+ as typed readers, the hit/fwd exclusivity surface, the section 2.2
41
+ fwd value set validated on emit only, and the append-yourself
42
+ operation. Fast::TargetedCacheControl implements RFC 9213 Targeted
43
+ HTTP Cache Control — the CDN-Cache-Control Dictionary of cache
44
+ directives with the section 2.1 type-inference rules enforced on
45
+ emit, the known-directive table as data, and a violating directive
46
+ preserved-but-flagged on parse. The two List fields share one
47
+ engine, Fast::ProxyStatus::ListField. One runtime dependency,
48
+ fast-sfv.
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - CHANGELOG.md
54
+ - README.md
55
+ - lib/fast/proxy_status.rb
56
+ - lib/fast/proxy_status/cache_status.rb
57
+ - lib/fast/proxy_status/errors.rb
58
+ - lib/fast/proxy_status/hop.rb
59
+ - lib/fast/proxy_status/list_field.rb
60
+ - lib/fast/proxy_status/registry.rb
61
+ - lib/fast/proxy_status/status.rb
62
+ - lib/fast/proxy_status/targeted_cache_control.rb
63
+ - lib/fast/proxy_status/version.rb
64
+ homepage: https://github.com/jetpks/fast-http-fields
65
+ licenses:
66
+ - MIT
67
+ metadata:
68
+ homepage_uri: https://github.com/jetpks/fast-http-fields
69
+ source_code_uri: https://github.com/jetpks/fast-http-fields
70
+ changelog_uri: https://github.com/jetpks/fast-http-fields/blob/main/gems/proxy_status/CHANGELOG.md
71
+ documentation_uri: https://github.com/jetpks/fast-http-fields/tree/main/gems/proxy_status/docs
72
+ rubygems_mfa_required: 'true'
73
+ rdoc_options: []
74
+ require_paths:
75
+ - lib
76
+ required_ruby_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '3.4'
81
+ required_rubygems_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: 3.5.3
86
+ requirements: []
87
+ rubygems_version: 4.0.20
88
+ specification_version: 4
89
+ summary: 'RFC 9209, 9211 and 9213 response fields: Proxy-Status, Cache-Status and
90
+ Targeted Cache Control.'
91
+ test_files: []