protocol-http 0.46.0 → 0.47.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 753df89051cc0eeff1cab5100a4ebc2a98e11bd3dce4a3fbcba890406c198c32
4
- data.tar.gz: dbc6b80efe3fc8a430839868f160151a9490336cc39423e31cfd851076b72947
3
+ metadata.gz: f53b02520f9b41a2cf01a8e2637c7331dbfbd330ad13487036c2af363e948c2d
4
+ data.tar.gz: 803588a8a92cc588e027dd285c8d76705d4fb137e2a5fa9566b2897d1473be38
5
5
  SHA512:
6
- metadata.gz: 104b449c9a3beaaf7f3c50e28eb21df3f2bef95b89ec954bd20a808a09b508f69d8e0387d6b41ed8e7dc02e41a85bc1116ff8f775694c4e0b26c3899b248f310
7
- data.tar.gz: 3ea2e87c3375055aa89f8d9b73b549854cb53ecb90bf6ee3f75ffc4c4ae8b7fbb61b10119fbdb0d125287aea03c894c7327b79ee410d28a771faab24e2fcafa5
6
+ metadata.gz: a6cb23fc1e47567145ad6d30ab12b4157e3f5962de8a32c38702bdb979c5f9c9388f6b480104655a77dd83c42c5e3230b471efe683acda76e0a2576f0fd654e4
7
+ data.tar.gz: e61af805d44b682ad9da0de0753b6009a96ace3b68799a597523ac6d74d847923d810e2cc20ded2df569a57505c7a2abb768714153f47a46586df6ce9e9dd086
checksums.yaml.gz.sig CHANGED
Binary file
@@ -10,54 +10,44 @@ module Protocol
10
10
  module Header
11
11
  # Represents the `priority` header, used to indicate the relative importance of an HTTP request.
12
12
  #
13
- # The `priority` header allows clients to express their preference for how resources should be prioritized by the server. It can include directives like `urgency` to specify the importance of a request, and `progressive` to indicate whether a response can be delivered incrementally.
13
+ # The `priority` header allows clients to express their preference for how resources should be prioritized by the server. It supports directives like `u=` to specify the urgency level of a request, and `i` to indicate whether a response can be delivered incrementally. The urgency levels range from 0 (highest priority) to 7 (lowest priority), while the `i` directive is a boolean flag.
14
14
  class Priority < Split
15
- # Urgency levels as defined in RFC 9218:
16
- #
17
- # These levels indicate the relative importance of a request, helping servers and intermediaries allocate resources efficiently. Properly setting urgency can significantly improve user-perceived performance by prioritizing critical content and deferring less important tasks.
18
- module Urgency
19
- # `background` priority indicates a request that is not time-sensitive and can be processed with minimal impact to other tasks. It is ideal for requests like analytics or logging, which do not directly impact the user's current experience.
20
- BACKGROUND = "background"
21
-
22
- # `low` priority indicates a request that is important but not critical. It is suitable for content like non-blocking images, videos, or scripts that enhance the experience but do not affect core functionality.
23
- LOW = "low"
24
-
25
- # `normal` priority (default) indicates the standard priority for most requests. It is appropriate for content like text, CSS, or essential images that are necessary for the primary user experience but do not require urgent delivery.
26
- NORMAL = "normal"
27
-
28
- # `high` priority indicates the highest priority, used for requests that are essential and time-critical to the user experience. Examples include content above-the-fold on a webpage, critical API calls, or resources required for rendering.
29
- HIGH = "high"
30
- end
31
-
32
- # The `progressive` flag indicates that the response can be delivered incrementally (progressively) as data becomes available. This is particularly useful for large resources like images or video streams, where partial delivery improves the user experience by allowing content to render or play before the full response is received.
33
- PROGRESSIVE = "progressive"
34
-
35
15
  # Initialize the priority header with the given value.
36
16
  #
37
- # @parameter value [String | Nil] the value of the priority header, if any.
17
+ # @parameter value [String | Nil] the value of the priority header, if any. The value should be a comma-separated string of directives.
38
18
  def initialize(value = nil)
39
19
  super(value&.downcase)
40
20
  end
41
21
 
42
22
  # Add a value to the priority header.
23
+ #
24
+ # @parameter value [String] the directive to add to the header.
43
25
  def << value
44
26
  super(value.downcase)
45
27
  end
46
28
 
47
- # Returns the urgency level if specified.
29
+ # The default urgency level if not specified.
30
+ DEFAULT_URGENCY = 3
31
+
32
+ # Returns the urgency level if specified. 0 is the highest priority, and 7 is the lowest.
48
33
  #
49
- # @returns [String | Nil] the urgency level if specified, or `nil`.
50
- def urgency
51
- if value = self.find{|value| value.start_with?("urgency=")}
34
+ # @returns [Integer | Nil] the urgency level if specified, or `nil` if not present.
35
+ def urgency(default = DEFAULT_URGENCY)
36
+ if value = self.find { |value| value.start_with?("u=") }
52
37
  _, level = value.split("=", 2)
53
-
54
- return level
38
+ return level.to_i
55
39
  end
40
+
41
+ return default
56
42
  end
57
43
 
58
- # @returns [Boolean] whether the request should be delivered progressively.
59
- def progressive?
60
- self.include?(PROGRESSIVE)
44
+ # Checks if the response should be delivered incrementally.
45
+ #
46
+ # The `i` directive, when present, indicates that the response can be delivered incrementally as data becomes available.
47
+ #
48
+ # @returns [Boolean] whether the request should be delivered incrementally.
49
+ def incremental?
50
+ self.include?("i")
61
51
  end
62
52
  end
63
53
  end
@@ -5,6 +5,6 @@
5
5
 
6
6
  module Protocol
7
7
  module HTTP
8
- VERSION = "0.46.0"
8
+ VERSION = "0.47.0"
9
9
  end
10
10
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: protocol-http
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.46.0
4
+ version: 0.47.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
metadata.gz.sig CHANGED
Binary file