async-http-cache 0.4.4 → 0.4.5
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/async/http/cache/body.rb +7 -7
- data/lib/async/http/cache/general.rb +14 -14
- data/lib/async/http/cache/response.rb +6 -6
- data/lib/async/http/cache/store/memory.rb +1 -1
- data/lib/async/http/cache/store/vary.rb +2 -2
- data/lib/async/http/cache/store.rb +2 -2
- data/lib/async/http/cache/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +3 -8
- 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: 5ef0cd31192b81f8fc4acfefdb378d2ae673ec004b572555e1c1298a0afa5ba6
|
4
|
+
data.tar.gz: 554b926efed070b44a672c2e422cf7be1aa243cd619ab4260210d468321ff044
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8e688e64d6cf8e734f80ef3cf1422de4b5ae89055d926b047c80d39ef2c23c70a5e085082e86a70fa09d912767505fc2bcaed1d837c3c3c1ce50a45efd3cc7e
|
7
|
+
data.tar.gz: 3e702d6db9c8764fd0d2932ba9bc3a27aafc76b001380f2dee77fcc4ceae350044593d36cb3661b945bda78f47bb951db43fa6b99d7fab5e51732a50d3cc3e18
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
@@ -3,19 +3,19 @@
|
|
3
3
|
# Released under the MIT License.
|
4
4
|
# Copyright, 2020-2024, by Samuel Williams.
|
5
5
|
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
6
|
+
require "protocol/http/body/rewindable"
|
7
|
+
require "protocol/http/body/completable"
|
8
|
+
require "protocol/http/body/digestable"
|
9
9
|
|
10
|
-
require
|
11
|
-
require
|
10
|
+
require "console"
|
11
|
+
require "console/event/failure"
|
12
12
|
|
13
13
|
module Async
|
14
14
|
module HTTP
|
15
15
|
module Cache
|
16
16
|
module Body
|
17
|
-
TRAILER =
|
18
|
-
ETAG =
|
17
|
+
TRAILER = "trailer"
|
18
|
+
ETAG = "etag"
|
19
19
|
|
20
20
|
def self.wrap(response, &block)
|
21
21
|
if body = response.body
|
@@ -4,24 +4,24 @@
|
|
4
4
|
# Copyright, 2020-2024, by Samuel Williams.
|
5
5
|
# Copyright, 2022, by Colin Kelley.
|
6
6
|
|
7
|
-
require
|
8
|
-
require
|
7
|
+
require "set"
|
8
|
+
require "protocol/http/middleware"
|
9
9
|
|
10
|
-
require_relative
|
11
|
-
require_relative
|
12
|
-
require_relative
|
10
|
+
require_relative "body"
|
11
|
+
require_relative "response"
|
12
|
+
require_relative "store"
|
13
13
|
|
14
14
|
module Async
|
15
15
|
module HTTP
|
16
16
|
module Cache
|
17
17
|
# Implements a general shared cache according to https://www.rfc-editor.org/rfc/rfc9111
|
18
18
|
class General < ::Protocol::HTTP::Middleware
|
19
|
-
CACHE_CONTROL =
|
19
|
+
CACHE_CONTROL = "cache-control"
|
20
20
|
|
21
|
-
CONTENT_TYPE =
|
22
|
-
AUTHORIZATION =
|
23
|
-
COOKIE =
|
24
|
-
SET_COOKIE =
|
21
|
+
CONTENT_TYPE = "content-type"
|
22
|
+
AUTHORIZATION = "authorization"
|
23
|
+
COOKIE = "cookie"
|
24
|
+
SET_COOKIE = "set-cookie"
|
25
25
|
|
26
26
|
# Status codes of responses that MAY be stored by a cache or used in reply
|
27
27
|
# to a subsequent request.
|
@@ -72,7 +72,7 @@ module Async
|
|
72
72
|
end
|
73
73
|
|
74
74
|
# We only support caching GET and HEAD requests:
|
75
|
-
unless request.method ==
|
75
|
+
unless request.method == "GET" || request.method == "HEAD"
|
76
76
|
return false
|
77
77
|
end
|
78
78
|
|
@@ -111,7 +111,7 @@ module Async
|
|
111
111
|
Console.logger.debug(self, status: response.status) {"Cannot cache response with status code!"}
|
112
112
|
return false
|
113
113
|
end
|
114
|
-
|
114
|
+
|
115
115
|
unless cacheable_response_headers?(response.headers)
|
116
116
|
Console.logger.debug(self) {"Cannot cache response with uncacheable headers!"}
|
117
117
|
return false
|
@@ -137,7 +137,7 @@ module Async
|
|
137
137
|
if request.head? and body = response.body
|
138
138
|
unless body.empty?
|
139
139
|
Console.logger.warn(self) {"HEAD request resulted in non-empty body!"}
|
140
|
-
|
140
|
+
|
141
141
|
return response
|
142
142
|
end
|
143
143
|
end
|
@@ -161,7 +161,7 @@ module Async
|
|
161
161
|
end
|
162
162
|
end
|
163
163
|
end
|
164
|
-
|
164
|
+
|
165
165
|
def call(request)
|
166
166
|
cache_control = request.headers[CACHE_CONTROL]
|
167
167
|
|
@@ -3,17 +3,17 @@
|
|
3
3
|
# Released under the MIT License.
|
4
4
|
# Copyright, 2020-2024, by Samuel Williams.
|
5
5
|
|
6
|
-
require
|
7
|
-
require
|
6
|
+
require "protocol/http/response"
|
7
|
+
require "async/clock"
|
8
8
|
|
9
9
|
module Async
|
10
10
|
module HTTP
|
11
11
|
module Cache
|
12
12
|
class Response < ::Protocol::HTTP::Response
|
13
|
-
CACHE_CONTROL =
|
14
|
-
ETAG =
|
13
|
+
CACHE_CONTROL = "cache-control"
|
14
|
+
ETAG = "etag"
|
15
15
|
|
16
|
-
X_CACHE =
|
16
|
+
X_CACHE = "x-cache"
|
17
17
|
|
18
18
|
def initialize(response, body)
|
19
19
|
@generated_at = Async::Clock.now
|
@@ -29,7 +29,7 @@ module Async
|
|
29
29
|
@max_age = @headers[CACHE_CONTROL]&.max_age
|
30
30
|
@etag = nil
|
31
31
|
|
32
|
-
@headers.set(X_CACHE,
|
32
|
+
@headers.set(X_CACHE, "hit")
|
33
33
|
end
|
34
34
|
|
35
35
|
attr :generated_at
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: async-http-cache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
- Colin Kelley
|
9
9
|
- Olle Jonsson
|
10
|
-
autorequire:
|
11
10
|
bindir: bin
|
12
11
|
cert_chain:
|
13
12
|
- |
|
@@ -39,7 +38,7 @@ cert_chain:
|
|
39
38
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
40
39
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
41
40
|
-----END CERTIFICATE-----
|
42
|
-
date:
|
41
|
+
date: 2025-03-04 00:00:00.000000000 Z
|
43
42
|
dependencies:
|
44
43
|
- !ruby/object:Gem::Dependency
|
45
44
|
name: async-http
|
@@ -55,8 +54,6 @@ dependencies:
|
|
55
54
|
- - "~>"
|
56
55
|
- !ruby/object:Gem::Version
|
57
56
|
version: '0.56'
|
58
|
-
description:
|
59
|
-
email:
|
60
57
|
executables: []
|
61
58
|
extensions: []
|
62
59
|
extra_rdoc_files: []
|
@@ -76,7 +73,6 @@ licenses:
|
|
76
73
|
- MIT
|
77
74
|
metadata:
|
78
75
|
source_code_uri: https://github.com/socketry/async-http-cache.git
|
79
|
-
post_install_message:
|
80
76
|
rdoc_options: []
|
81
77
|
require_paths:
|
82
78
|
- lib
|
@@ -91,8 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
91
87
|
- !ruby/object:Gem::Version
|
92
88
|
version: '0'
|
93
89
|
requirements: []
|
94
|
-
rubygems_version: 3.
|
95
|
-
signing_key:
|
90
|
+
rubygems_version: 3.6.2
|
96
91
|
specification_version: 4
|
97
92
|
summary: Standard-compliant cache for async-http.
|
98
93
|
test_files: []
|
metadata.gz.sig
CHANGED
Binary file
|