protocol-http 0.24.7 → 0.25.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
- checksums.yaml.gz.sig +0 -0
- data/lib/protocol/http/header/cache_control.rb +36 -2
- data/lib/protocol/http/header/etags.rb +22 -1
- data/lib/protocol/http/response.rb +21 -0
- data/lib/protocol/http/version.rb +1 -1
- data/license.md +1 -0
- 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: 6354e91389524cbc79fb186bb3d5f3a3bc87ff3a904fc1540635ec8bf89db448
|
4
|
+
data.tar.gz: f83f86976e9dfb6ed8f8adab3f587acf0359377f6254627099ecbc504a3145db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72fdbf93d17bf20fae9591620b0c64a99f02026e677311486a0e7ee94d6b2fdce62063b3bbd31a0e6941ba3f324acc99a0957edba610d659fce1e1e9247ad34e
|
7
|
+
data.tar.gz: 3280e4a0d39fa6a4ab58ab08c1dfeb2cad6e5ddbddc73906f00552a6c32dab3669e67c86d22f92dafa236745f11d8d75961c398f932cf4790cbe67deeb6807d0
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
4
|
# Copyright, 2020-2023, by Samuel Williams.
|
5
|
+
# Copyright, 2023, by Thomas Morgan.
|
5
6
|
|
6
7
|
require_relative 'split'
|
7
8
|
|
@@ -14,11 +15,15 @@ module Protocol
|
|
14
15
|
NO_CACHE = 'no-cache'
|
15
16
|
NO_STORE = 'no-store'
|
16
17
|
MAX_AGE = 'max-age'
|
18
|
+
S_MAXAGE = 's-maxage'
|
17
19
|
|
18
20
|
STATIC = 'static'
|
19
21
|
DYNAMIC = 'dynamic'
|
20
22
|
STREAMING = 'streaming'
|
21
23
|
|
24
|
+
MUST_REVALIDATE = 'must-revalidate'
|
25
|
+
PROXY_REVALIDATE = 'proxy-revalidate'
|
26
|
+
|
22
27
|
def initialize(value = nil)
|
23
28
|
super(value&.downcase)
|
24
29
|
end
|
@@ -55,11 +60,40 @@ module Protocol
|
|
55
60
|
self.include?(NO_STORE)
|
56
61
|
end
|
57
62
|
|
63
|
+
# Indicates that a response must not be used once it is stale.
|
64
|
+
# See https://www.rfc-editor.org/rfc/rfc9111.html#name-must-revalidate
|
65
|
+
def must_revalidate?
|
66
|
+
self.include?(MUST_REVALIDATE)
|
67
|
+
end
|
68
|
+
|
69
|
+
# Like must-revalidate, but for shared caches only.
|
70
|
+
# See https://www.rfc-editor.org/rfc/rfc9111.html#name-proxy-revalidate
|
71
|
+
def proxy_revalidate?
|
72
|
+
self.include?(PROXY_REVALIDATE)
|
73
|
+
end
|
74
|
+
|
75
|
+
# The maximum time, in seconds, a response should be considered fresh.
|
76
|
+
# See https://www.rfc-editor.org/rfc/rfc9111.html#name-max-age-2
|
58
77
|
def max_age
|
59
|
-
|
78
|
+
find_integer_value(MAX_AGE)
|
79
|
+
end
|
80
|
+
|
81
|
+
# Like max-age, but for shared caches only, which should use it before
|
82
|
+
# max-age when present.
|
83
|
+
# See https://www.rfc-editor.org/rfc/rfc9111.html#name-s-maxage
|
84
|
+
def s_maxage
|
85
|
+
find_integer_value(S_MAXAGE)
|
86
|
+
end
|
87
|
+
|
88
|
+
private
|
89
|
+
|
90
|
+
def find_integer_value(value_name)
|
91
|
+
if value = self.find{|value| value.start_with?(value_name)}
|
60
92
|
_, age = value.split('=', 2)
|
61
93
|
|
62
|
-
|
94
|
+
if age =~ /\A[0-9]+\z/
|
95
|
+
return Integer(age)
|
96
|
+
end
|
63
97
|
end
|
64
98
|
end
|
65
99
|
end
|
@@ -2,21 +2,42 @@
|
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
4
|
# Copyright, 2020-2023, by Samuel Williams.
|
5
|
+
# Copyright, 2023, by Thomas Morgan.
|
5
6
|
|
6
7
|
require_relative 'split'
|
7
8
|
|
8
9
|
module Protocol
|
9
10
|
module HTTP
|
10
11
|
module Header
|
11
|
-
# This implementation is not strictly correct according to the RFC-specified format.
|
12
12
|
class ETags < Split
|
13
13
|
def wildcard?
|
14
14
|
self.include?('*')
|
15
15
|
end
|
16
16
|
|
17
|
+
# This implementation is not strictly correct according to the RFC-specified format.
|
17
18
|
def match?(etag)
|
18
19
|
wildcard? || self.include?(etag)
|
19
20
|
end
|
21
|
+
|
22
|
+
# Useful with If-Match
|
23
|
+
def strong_match?(etag)
|
24
|
+
wildcard? || (!weak_tag?(etag) && self.include?(etag))
|
25
|
+
end
|
26
|
+
|
27
|
+
# Useful with If-None-Match
|
28
|
+
def weak_match?(etag)
|
29
|
+
wildcard? || self.include?(etag) || self.include?(opposite_tag(etag))
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def opposite_tag(etag)
|
35
|
+
weak_tag?(etag) ? etag[2..-1] : "W/#{etag}"
|
36
|
+
end
|
37
|
+
|
38
|
+
def weak_tag?(tag)
|
39
|
+
tag&.start_with? 'W/'
|
40
|
+
end
|
20
41
|
end
|
21
42
|
end
|
22
43
|
end
|
@@ -29,42 +29,63 @@ module Protocol
|
|
29
29
|
false
|
30
30
|
end
|
31
31
|
|
32
|
+
# Whether the status is 100 (continue).
|
32
33
|
def continue?
|
33
34
|
@status == 100
|
34
35
|
end
|
35
36
|
|
37
|
+
# Whether the status is considered informational.
|
38
|
+
def informational?
|
39
|
+
@status and @status >= 100 && @status < 200
|
40
|
+
end
|
41
|
+
|
42
|
+
# Whether the status is considered final. Note that 101 is considered final.
|
43
|
+
def final?
|
44
|
+
# 101 is effectively a final status.
|
45
|
+
@status and @status >= 200 || @status == 101
|
46
|
+
end
|
47
|
+
|
48
|
+
# Whether the status is 200 (ok).
|
36
49
|
def ok?
|
37
50
|
@status == 200
|
38
51
|
end
|
39
52
|
|
53
|
+
# Whether the status is considered successful.
|
40
54
|
def success?
|
41
55
|
@status and @status >= 200 && @status < 300
|
42
56
|
end
|
43
57
|
|
58
|
+
# Whether the status is 206 (partial content).
|
44
59
|
def partial?
|
45
60
|
@status == 206
|
46
61
|
end
|
47
62
|
|
63
|
+
# Whether the status is considered a redirection.
|
48
64
|
def redirection?
|
49
65
|
@status and @status >= 300 && @status < 400
|
50
66
|
end
|
51
67
|
|
68
|
+
# Whether the status is 304 (not modified).
|
52
69
|
def not_modified?
|
53
70
|
@status == 304
|
54
71
|
end
|
55
72
|
|
73
|
+
# Whether the status is 307 (temporary redirect) and should preserve the method of the request when following the redirect.
|
56
74
|
def preserve_method?
|
57
75
|
@status == 307 || @status == 308
|
58
76
|
end
|
59
77
|
|
78
|
+
# Whether the status is considered a failure.
|
60
79
|
def failure?
|
61
80
|
@status and @status >= 400 && @status < 600
|
62
81
|
end
|
63
82
|
|
83
|
+
# Whether the status is 400 (bad request).
|
64
84
|
def bad_request?
|
65
85
|
@status == 400
|
66
86
|
end
|
67
87
|
|
88
|
+
# Whether the status is 500 (internal server error).
|
68
89
|
def internal_server_error?
|
69
90
|
@status == 500
|
70
91
|
end
|
data/license.md
CHANGED
@@ -8,6 +8,7 @@ Copyright, 2020-2023, by Bruno Sutic.
|
|
8
8
|
Copyright, 2022, by Herrick Fang.
|
9
9
|
Copyright, 2022, by Dan Olson.
|
10
10
|
Copyright, 2023, by Genki Takiuchi.
|
11
|
+
Copyright, 2023, by Thomas Morgan.
|
11
12
|
|
12
13
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
13
14
|
of this software and associated documentation files (the "Software"), to deal
|
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.25.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -44,7 +44,7 @@ cert_chain:
|
|
44
44
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
45
45
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
46
46
|
-----END CERTIFICATE-----
|
47
|
-
date: 2023-
|
47
|
+
date: 2023-09-12 00:00:00.000000000 Z
|
48
48
|
dependencies: []
|
49
49
|
description:
|
50
50
|
email:
|
metadata.gz.sig
CHANGED
Binary file
|