From a1f75c86ad5a8111375234e4a5d5eb634d14cb6f Mon Sep 17 00:00:00 2001 From: himura467 Date: Mon, 2 Nov 2026 15:26:23 +0900 Subject: [PATCH] fix: treat 205 as carrying no content --- SPEC.md | 2 +- lib/nack/spec.rb | 2 +- test/spec_spec.rb | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/SPEC.md b/SPEC.md index 603784c..d1a94fe 100644 --- a/SPEC.md +++ b/SPEC.md @@ -96,7 +96,7 @@ Requests that arrived on one connection MAY be in flight at the same time (secti `body` MUST be `nil` (empty), a `String` (its bytes are used as-is; encoding is not interpreted), an `IO::Buffer` (its backing bytes are used without an intermediate String), or an object responding to `#each`. -The bridge enumerates such a body at most once: it calls `#each` with a block, and the body yields each chunk to that block as a `String` or an `IO::Buffer`. The block MAY take arbitrarily long to return, which is how the host's backpressure reaches the application. The bridge MUST NOT pass on a zero-length chunk. A response to HEAD, a 204 and a 304 carry no content, so the bridge need not enumerate their bodies. +The bridge enumerates such a body at most once: it calls `#each` with a block, and the body yields each chunk to that block as a `String` or an `IO::Buffer`. The block MAY take arbitrarily long to return, which is how the host's backpressure reaches the application. The bridge MUST NOT pass on a zero-length chunk. A response to HEAD, a 204, a 205 and a 304 carry no content, so the bridge need not enumerate their bodies. The bridge MAY stop enumerating before the body is complete, so a body with side effects MUST tolerate being abandoned part-way. The bridge MUST call `#close` on a body that responds to it once it is finished with the body, whether or not it enumerated the body to completion. diff --git a/lib/nack/spec.rb b/lib/nack/spec.rb index cf086b5..e5acde4 100644 --- a/lib/nack/spec.rb +++ b/lib/nack/spec.rb @@ -31,7 +31,7 @@ def valid_content_length?(value) def no_entity_body?(status, request) request.request_method.get_string == "HEAD" || - ((100..199).cover?(status) && status != 101) || status == 204 || status == 304 + ((100..199).cover?(status) && status != 101) || status == 204 || status == 205 || status == 304 end def valid_interim_status?(status) diff --git a/test/spec_spec.rb b/test/spec_spec.rb index 05fe8a2..1818853 100644 --- a/test/spec_spec.rb +++ b/test/spec_spec.rb @@ -59,6 +59,7 @@ Nack::Spec.no_entity_body?(100, get).must_equal true Nack::Spec.no_entity_body?(199, get).must_equal true Nack::Spec.no_entity_body?(204, get).must_equal true + Nack::Spec.no_entity_body?(205, get).must_equal true Nack::Spec.no_entity_body?(304, get).must_equal true Nack::Spec.no_entity_body?(200, head).must_equal true Nack::Spec.no_entity_body?(101, get).must_equal false