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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/protocol/http/header/priority.rb +21 -31
- data/lib/protocol/http/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f53b02520f9b41a2cf01a8e2637c7331dbfbd330ad13487036c2af363e948c2d
|
4
|
+
data.tar.gz: 803588a8a92cc588e027dd285c8d76705d4fb137e2a5fa9566b2897d1473be38
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
-
#
|
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 [
|
50
|
-
def urgency
|
51
|
-
if value = self.find{|value| value.start_with?("
|
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
|
-
#
|
59
|
-
|
60
|
-
|
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
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|