Skip to content

Commit 63cbb0a

Browse files
config: Clarify that new blocking codes are valid HTTP codes >=300 (300-599).
1 parent f330a55 commit 63cbb0a

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Unreleased
44

5-
* Deprecated the `AltResponseCodes` concept in favor of using all code 300 and higher as "blocking"
5+
* Deprecated the `AltResponseCodes` concept in favor of using all codes 300-599 as "blocking"
66

77
## 1.7.1 2020-04-06
88

config.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func (c *ModuleConfig) SetOptions(options ...ModuleConfigOption) error {
9696

9797
// IsBlockCode returns true if the code is a configured block code
9898
func (c *ModuleConfig) IsBlockCode(code int) bool {
99-
return code >= 300
99+
return code >= 300 && code <= 599
100100
}
101101

102102
// IsAllowCode returns true if the code is an allow code
@@ -113,7 +113,7 @@ func (c *ModuleConfig) AllowUnknownContentLength() bool {
113113
//
114114
// Deprecated: The `AltResponseCodes` concept has
115115
// been deprecated in favor of treating all response
116-
// codes 300 and greater as blocking codes. Due to
116+
// codes 300-599 as blocking codes. Due to
117117
// this, this method will always return nil. It is left
118118
// here to avoid breakage, but will eventually be removed.
119119
func (c *ModuleConfig) AltResponseCodes() []int {
@@ -216,7 +216,7 @@ func AllowUnknownContentLength(allow bool) ModuleConfigOption {
216216
//
217217
// Deprecated: The `AltResponseCodes` concept has
218218
// been deprecated in favor of treating all response
219-
// codes 300 and greater as blocking codes. Due to
219+
// codes 300-599 as blocking codes. Due to
220220
// this, this method will always return nil. It is left
221221
// here to avoid breakage, but will eventually be removed.
222222
func AltResponseCodes(codes ...int) ModuleConfigOption {

config_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ func TestDefaultModuleConfig(t *testing.T) {
7272
t.Errorf("Unexpected IsBlockCode(%d): %v", code, c.IsBlockCode(code))
7373
}
7474
}
75+
if c.IsBlockCode(600) {
76+
t.Errorf("Unexpected IsBlockCode(600): %v", c.IsBlockCode(600))
77+
}
7578
if c.IsBlockCode(200) {
7679
t.Errorf("Unexpected IsBlockCode(200): %v", c.IsBlockCode(200))
7780
}
@@ -154,6 +157,9 @@ func TestConfiguredModuleConfig(t *testing.T) {
154157
t.Errorf("Unexpected IsBlockCode(%d): %v", code, c.IsBlockCode(code))
155158
}
156159
}
160+
if c.IsBlockCode(600) {
161+
t.Errorf("Unexpected IsBlockCode(600): %v", c.IsBlockCode(600))
162+
}
157163
if c.IsBlockCode(200) {
158164
t.Errorf("Unexpected IsBlockCode(200): %v", c.IsBlockCode(200))
159165
}
@@ -243,6 +249,9 @@ func TestFromModuleConfig(t *testing.T) {
243249
t.Errorf("Unexpected IsBlockCode(%d): %v", code, c.IsBlockCode(code))
244250
}
245251
}
252+
if c.IsBlockCode(600) {
253+
t.Errorf("Unexpected IsBlockCode(600): %v", c.IsBlockCode(600))
254+
}
246255
if c.IsBlockCode(200) {
247256
t.Errorf("Unexpected IsBlockCode(200): %v", c.IsBlockCode(200))
248257
}

0 commit comments

Comments
 (0)