rack-steady_etag 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -1
- data/Gemfile.lock +3 -3
- data/README.md +4 -2
- data/lib/rack/steady_etag/version.rb +1 -1
- data/lib/rack/steady_etag.rb +7 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8caa8d352b72433a6659f50b6c9216cf03b265b19016134fa259719d24c46b4e
|
4
|
+
data.tar.gz: 74f01fc86755933b87361615bd6cb62568e44bfa404565261c0c180dcd5b399c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3cbd8de00297924f758d0c32151d17991fe8e235d943969544cdad632f50cca43eba12ef133c1a7690d91def4d8f997ab48535417457f62c8cb9d36a07a7e9d9
|
7
|
+
data.tar.gz: c2df595d03a3e3f46b2be21f4da14f76460556a0b8e6628959d7156d1a5285c79eb9c1a45415ad343904ed388c4645320ddc94a2422184727798d4b432eecd2e
|
data/CHANGELOG.md
CHANGED
@@ -5,13 +5,17 @@ This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html
|
|
5
5
|
|
6
6
|
## Unreleased
|
7
7
|
|
8
|
+
## 0.2.2 - 2022-05-12
|
9
|
+
|
10
|
+
- Don't raise an error when processing binary content.
|
11
|
+
|
8
12
|
## 0.2.1 - 2022-05-12
|
9
13
|
|
10
14
|
- Only strip patterns for HTML and XHTML responses.
|
11
15
|
|
12
16
|
## 0.2.0 - 2022-05-12
|
13
17
|
|
14
|
-
- Be more compatible with Rack 2.2.
|
18
|
+
- Be more compatible with Rack 2.2.3:
|
15
19
|
- Always set a `Cache-Control` header, even for responses that we don't try to digest.
|
16
20
|
- Strip patterns for responses with `Cache-Control: public`
|
17
21
|
- Requires Rack 2.x (we want to break with Rack 3)
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rack-steady_etag (0.2.
|
4
|
+
rack-steady_etag (0.2.2)
|
5
5
|
activesupport (>= 3.2)
|
6
6
|
rack (~> 2.0)
|
7
7
|
|
@@ -14,9 +14,9 @@ GEM
|
|
14
14
|
minitest (>= 5.1)
|
15
15
|
tzinfo (~> 2.0)
|
16
16
|
byebug (11.1.3)
|
17
|
-
concurrent-ruby (1.1.
|
17
|
+
concurrent-ruby (1.1.10)
|
18
18
|
diff-lcs (1.4.4)
|
19
|
-
i18n (1.
|
19
|
+
i18n (1.10.0)
|
20
20
|
concurrent-ruby (~> 1.0)
|
21
21
|
minitest (5.15.0)
|
22
22
|
rack (2.2.3)
|
data/README.md
CHANGED
@@ -35,10 +35,12 @@ Transformations are only applied for the `ETag` hash. The response body will not
|
|
35
35
|
|
36
36
|
This middleware will process responses that match all of the following:
|
37
37
|
|
38
|
-
- Responses with a HTTP status of 200 or 201
|
39
|
-
- Responses with a `Content-Type` of `text/html` or `application/xhtml+xml
|
38
|
+
- Responses with a HTTP status of 200 or 201.
|
39
|
+
- Responses with a `Content-Type` of `text/html` or `application/xhtml+xml`.
|
40
40
|
- Responses with a body.
|
41
41
|
|
42
|
+
Responses should also have an UTF-8 encoding (not checked by the middleware).
|
43
|
+
|
42
44
|
This middleware can also add a default `Cache-Control` header for responses it *didn't* process. This is passed as an argument during middleware initialization (see *Installation* below).
|
43
45
|
|
44
46
|
## Covered edge cases
|
data/lib/rack/steady_etag.rb
CHANGED
@@ -6,8 +6,8 @@ require_relative "steady_etag/version"
|
|
6
6
|
|
7
7
|
module Rack
|
8
8
|
|
9
|
-
# Based on Rack::Etag from rack 2.2.
|
10
|
-
# https://github.com/rack/rack/blob/v2.2.
|
9
|
+
# Based on Rack::Etag from rack 2.2.3
|
10
|
+
# https://github.com/rack/rack/blob/v2.2.3/lib/rack/etag.rb
|
11
11
|
#
|
12
12
|
# Automatically sets the ETag header on all String bodies.
|
13
13
|
#
|
@@ -87,7 +87,7 @@ module Rack
|
|
87
87
|
def etag_body?(body)
|
88
88
|
# Rack main branch checks for `:to_ary` here to exclude streaming responses,
|
89
89
|
# but that had other issues for me in testing. Maybe recheck when there is a
|
90
|
-
# new Rack release after 2.2.
|
90
|
+
# new Rack release after 2.2.3.
|
91
91
|
!body.respond_to?(:to_path)
|
92
92
|
end
|
93
93
|
|
@@ -104,7 +104,10 @@ module Rack
|
|
104
104
|
body.each do |part|
|
105
105
|
parts << part
|
106
106
|
|
107
|
-
|
107
|
+
# Note that `part` can be a string with binary data here.
|
108
|
+
# It's important to check emptiness with #empty? instead of #blank?, since #blank?
|
109
|
+
# internally calls String#match? and that explodes if the string is not valid UTF-8.
|
110
|
+
unless part.empty?
|
108
111
|
digest ||= initialize_digest(session)
|
109
112
|
part = strip_patterns(part) if strippable_response
|
110
113
|
digest << part
|