Skip to content
This repository was archived by the owner on Dec 3, 2019. It is now read-only.

Commit f108ed1

Browse files
committed
Errors caused by empty HTTP headers. Closes #8
1 parent ca14542 commit f108ed1

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 0.1.16 (2015-04-29)
4+
5+
* Errors caused by empty HTTP headers. Fixes issue #8
6+
37
## 0.1.15 (2015-04-29)
48

59
* No max-stale = allow anything. Fixes issue #7

lib/formatting.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def format_key
3030
def clean
3131
->(headers) {
3232
Array(headers).reject {|key, value|
33-
HEADERS_NO_CACHE.include?(key) || helper_is_if_modified_error?(key, value)
33+
HEADERS_NO_CACHE.include?(key) || helper_is_if_modified_error?(key, value) || value.nil? || value.empty?
3434
}
3535
}
3636
end

test/test_regressions.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,13 @@ def test_bugfix_7_invalid_validation_of_max_stale
3535

3636
assert_kind_of TrueClass, no_max_stale
3737
end
38+
39+
# https://github.com/aw/CacheRules/issues/8
40+
def test_bugfix_8_errors_caused_by_empty_http_headers
41+
isnil = CacheRules.clean.call({'Content-Type'=>nil})
42+
isempty = CacheRules.clean.call({'Content-Type'=>''})
43+
44+
assert_equal isnil, []
45+
assert_equal isempty, []
46+
end
3847
end

0 commit comments

Comments
 (0)