protocol-http 0.46.0 → 0.47.1
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 +23 -31
- data/lib/protocol/http/header/split.rb +10 -0
- data/lib/protocol/http/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +2 -2
- 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: d8281f44eb94360f117cba9ef4770386d57b72049ec2200e45041f7b93193147
|
4
|
+
data.tar.gz: 0e93ed313a1a91971568b575b58db52857f15da6a92fe8764294f2b6ef2335c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f5765e41ef7706b20f8c82812099dc5e79fa6f5c9036332688e5dde9ea0a41a52d44a2442aa33d3514f977939f70c32b40fa858179d4bada70df5b70227e7ab
|
7
|
+
data.tar.gz: 8835f1c4351794d80db3c917b374648a2090c89619b9bd9deb556955a86eb230118814930d2b8d363838b49f0d2a75d7cee0f8f91bbc2393146cc8cecc9c4f68
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
@@ -10,54 +10,46 @@ 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
|
+
# The urgency level, if specified using `u=`. 0 is the highest priority, and 7 is the lowest.
|
33
|
+
#
|
34
|
+
# Note that when duplicate Dictionary keys are encountered, all but the last instance are ignored.
|
48
35
|
#
|
49
|
-
# @returns [
|
50
|
-
def urgency
|
51
|
-
if value = self.
|
36
|
+
# @returns [Integer | Nil] the urgency level if specified, or `nil` if not present.
|
37
|
+
def urgency(default = DEFAULT_URGENCY)
|
38
|
+
if value = self.reverse_find{|value| value.start_with?("u=")}
|
52
39
|
_, level = value.split("=", 2)
|
53
|
-
|
54
|
-
return level
|
40
|
+
return Integer(level)
|
55
41
|
end
|
42
|
+
|
43
|
+
return default
|
56
44
|
end
|
57
45
|
|
58
|
-
#
|
59
|
-
|
60
|
-
|
46
|
+
# Checks if the response should be delivered incrementally.
|
47
|
+
#
|
48
|
+
# The `i` directive, when present, indicates that the response can be delivered incrementally as data becomes available.
|
49
|
+
#
|
50
|
+
# @returns [Boolean] whether the request should be delivered incrementally.
|
51
|
+
def incremental?
|
52
|
+
self.include?("i")
|
61
53
|
end
|
62
54
|
end
|
63
55
|
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.
|
4
|
+
version: 0.47.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -47,7 +47,7 @@ cert_chain:
|
|
47
47
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
48
48
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
49
49
|
-----END CERTIFICATE-----
|
50
|
-
date: 2024-
|
50
|
+
date: 2024-12-04 00:00:00.000000000 Z
|
51
51
|
dependencies: []
|
52
52
|
description:
|
53
53
|
email:
|
metadata.gz.sig
CHANGED
Binary file
|