From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS15169 74.125.0.0/16 X-Spam-Status: No, score=-3.6 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,RCVD_IN_SORBS_SPAM,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 Received: from mail-wm0-f56.google.com (mail-wm0-f56.google.com [74.125.82.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 522241FF40 for ; Wed, 14 Dec 2016 22:14:58 +0000 (UTC) Received: by mail-wm0-f56.google.com with SMTP id g23sf5200146wme.1 for ; Wed, 14 Dec 2016 14:14:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:date:from:to:subject:message-id:mime-version :content-disposition:x-original-sender :x-original-authentication-results:reply-to:precedence:mailing-list :list-id:x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=EHW2NDd0tn+z48s/GgE/h703nK5kXGq25RsY/pmdArw=; b=sL5d/elQEFUByh85ecTYgRliGepJo2DzfWXxYfZXrApse2EV4h6jtB1NmPKlZDoHol +t0hGpCwQZDa+9RXajwUjTv5F/F9vjcQiqVhHQuxXEJCq7B9WJAit4YbK+luqScFgzk+ QcbpELw55ihFxEa7Obt+YJXlmkdbNNQC7EdpYqMPpks0IFgL7E38YFH7jKLZuYuKmxEW RnWXweHRML+W33QsWFuKu6shJKqrGjFd6ypgN3wXVKH01PD1lgJv2gdceB/nweS1fGZC gsiqa55ETZ0hk8rq6ErWfxQX387uF6c1owR58FH581puUnu2lWHdUgSAjXuu6XwJfhkd g9RA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:date:from:to:subject:message-id :mime-version:content-disposition:x-original-sender :x-original-authentication-results:reply-to:precedence:mailing-list :list-id:x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=EHW2NDd0tn+z48s/GgE/h703nK5kXGq25RsY/pmdArw=; b=avrxN5eTmJHrF/bpTxSf9Y1MC11v7nNPcj4JsUfRitMh4CK7kTAneEro1ZZe3evbfo e7xoOog6fkNdlC4v0k9g1H4TD1b9o2XDMKDPF1dGDq4rhyJ0s1JH4BV1Wnf9vug8uP1a ItO4yA7GMjHMps9bsYx54GJUh/wQR/dN1gUm32K5R4hO4SM6JDr/JK17pQFTL8Rts6EM K6LTgTrS9GSeQs4vOc7CqApcBlgh5Owl/v8K6iiNPRhajMPmf7Q3Dn7QYvUrx7breScs rRxboeY/qZjgKHVmcIHbLHr/cIWabflys7bL0VCRpXbvA13Zrfb0XXiKuukN2zZaDQif YeFQ== Sender: rack-devel@googlegroups.com X-Gm-Message-State: AKaTC00v555kvo1ZAEYxAi0XxkXco5mRMi4qLzOS2Sf9L+F5r9THCRDROZZUk9Qk18ojrw== X-Received: by 10.46.76.25 with SMTP id z25mr673046lja.10.1481753696620; Wed, 14 Dec 2016 14:14:56 -0800 (PST) X-BeenThere: rack-devel@googlegroups.com Received: by 10.25.24.221 with SMTP id 90ls139913lfy.24.gmail; Wed, 14 Dec 2016 14:14:55 -0800 (PST) X-Received: by 10.46.78.2 with SMTP id c2mr12845654ljb.20.1481753695967; Wed, 14 Dec 2016 14:14:55 -0800 (PST) Received: from dcvr.yhbt.net (dcvr.yhbt.net. [64.71.152.64]) by gmr-mx.google.com with ESMTPS id p138si1036167wme.1.2016.12.14.14.14.55 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Dec 2016 14:14:55 -0800 (PST) Received-SPF: pass (google.com: domain of e@80x24.org designates 64.71.152.64 as permitted sender) client-ip=64.71.152.64; Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 1982A1FF40; Wed, 14 Dec 2016 22:14:49 +0000 (UTC) Date: Wed, 14 Dec 2016 22:14:49 +0000 From: Eric Wong To: rack-devel@googlegroups.com Subject: [PATCH] Revert "Add 205 Reset Content to the list of statuses without a message body" Message-ID: <20161214221449.GA24731@dcvr> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Original-Sender: e@80x24.org X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of e@80x24.org designates 64.71.152.64 as permitted sender) smtp.mailfrom=e@80x24.org Reply-To: rack-devel@googlegroups.com Precedence: list Mailing-list: list rack-devel@googlegroups.com; contact rack-devel+owners@googlegroups.com List-ID: X-Google-Group-Id: 486215384060 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , RFC 7231, section 6.3.5 gives three possible options for what a server MUST do when sending a 205 status code: > Since the 205 status code implies that no additional content will be > provided, a server MUST NOT generate a payload in a 205 response. In > other words, a server MUST do one of the following for a 205 > response: a) indicate a zero-length body for the response by > including a Content-Length header field with a value of 0; b) > indicate a zero-length payload for the response by including a > Transfer-Encoding header field with a value of chunked and a message > body consisting of a single chunk of zero-length; or, c) close the > connection immediately after sending the blank line terminating the > header section. rack itself has no control over c), but should leave options a) and b) available for middleware and application authors. https://tools.ietf.org/html/rfc7231#section-6.3.6 The older RFC 2616 text was vague and not specific about what a server should do: https://tools.ietf.org/html/rfc2616#section-10.2.6 I noticed this from Plack: https://metacpan.org/pod/Plack::Util This reverts commit 2c5b076aaba6c83ffce8c6c2b5c49085c1abb5a5. --- If you prefer to use "git pull" or "git merge": The following changes since commit 9e73bd1ae7b5df937302a148ab99bf3be12eb063: Merge pull request #1135 from tonytonyjan/patch-rdoc (2016-12-08 13:13:44 -0500) are available in the git repository at: git://80x24.org/rack rfc7231-sec6.3.6-205 for you to fetch changes up to bcf2698bcc90f346b145538e53d0d61bcceb2e48: Revert "Add 205 Reset Content to the list of statuses without a message body" (2016-12-14 21:58:54 +0000) ---------------------------------------------------------------- Eric Wong (1): Revert "Add 205 Reset Content to the list of statuses without a message body" SPEC | 4 ++-- lib/rack/lint.rb | 4 ++-- lib/rack/mock.rb | 2 +- lib/rack/response.rb | 2 +- lib/rack/utils.rb | 2 +- test/spec_chunked.rb | 2 +- test/spec_lint.rb | 4 ++-- test/spec_response.rb | 4 ++-- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/SPEC b/SPEC index 7e3af40a..9b278846 100644 --- a/SPEC +++ b/SPEC @@ -237,10 +237,10 @@ consisting of lines (for multiple header values, e.g. multiple The lines must not contain characters below 037. === The Content-Type There must not be a Content-Type, when the +Status+ is 1xx, -204, 205 or 304. +204 or 304. === The Content-Length There must not be a Content-Length header when the -+Status+ is 1xx, 204, 205 or 304. ++Status+ is 1xx, 204 or 304. === The Body The Body must respond to +each+ and must only yield String values. diff --git a/lib/rack/lint.rb b/lib/rack/lint.rb index 54d37822..683ba684 100644 --- a/lib/rack/lint.rb +++ b/lib/rack/lint.rb @@ -659,7 +659,7 @@ module Rack def check_content_type(status, headers) headers.each { |key, value| ## There must not be a Content-Type, when the +Status+ is 1xx, - ## 204, 205 or 304. + ## 204 or 304. if key.downcase == "content-type" assert("Content-Type header found in #{status} response, not allowed") { not Rack::Utils::STATUS_WITH_NO_ENTITY_BODY.include? status.to_i @@ -674,7 +674,7 @@ module Rack headers.each { |key, value| if key.downcase == 'content-length' ## There must not be a Content-Length header when the - ## +Status+ is 1xx, 204, 205 or 304. + ## +Status+ is 1xx, 204 or 304. assert("Content-Length header found in #{status} response, not allowed") { not Rack::Utils::STATUS_WITH_NO_ENTITY_BODY.include? status.to_i } diff --git a/lib/rack/mock.rb b/lib/rack/mock.rb index 4ebc4df1..afc855e2 100644 --- a/lib/rack/mock.rb +++ b/lib/rack/mock.rb @@ -190,7 +190,7 @@ module Rack end def empty? - [201, 204, 205, 304].include? status + [201, 204, 304].include? status end end end diff --git a/lib/rack/response.rb b/lib/rack/response.rb index 9ac47aad..a9f0c2a3 100644 --- a/lib/rack/response.rb +++ b/lib/rack/response.rb @@ -60,7 +60,7 @@ module Rack def finish(&block) @block = block - if [204, 205, 304].include?(status.to_i) + if [204, 304].include?(status.to_i) delete_header CONTENT_TYPE delete_header CONTENT_LENGTH close diff --git a/lib/rack/utils.rb b/lib/rack/utils.rb index 7b842125..c253f3cf 100644 --- a/lib/rack/utils.rb +++ b/lib/rack/utils.rb @@ -576,7 +576,7 @@ module Rack } # Responses with HTTP status codes that should not have an entity body - STATUS_WITH_NO_ENTITY_BODY = Set.new((100..199).to_a << 204 << 205 << 304) + STATUS_WITH_NO_ENTITY_BODY = Set.new((100..199).to_a << 204 << 304) SYMBOL_TO_STATUS_CODE = Hash[*HTTP_STATUS_CODES.map { |code, message| [message.downcase.gsub(/\s|-|'/, '_').to_sym, code] diff --git a/test/spec_chunked.rb b/test/spec_chunked.rb index 7bbcfd92..dc6e8c9d 100644 --- a/test/spec_chunked.rb +++ b/test/spec_chunked.rb @@ -92,7 +92,7 @@ describe Rack::Chunked do body.join.must_equal 'Hello World!' end - [100, 204, 205, 304].each do |status_code| + [100, 204, 304].each do |status_code| it "not modify response when status code is #{status_code}" do app = lambda { |env| [status_code, {}, []] } status, headers, _ = chunked(app).call(@env) diff --git a/test/spec_lint.rb b/test/spec_lint.rb index 6d1c2c45..d99c1aa3 100644 --- a/test/spec_lint.rb +++ b/test/spec_lint.rb @@ -269,7 +269,7 @@ describe Rack::Lint do # }.must_raise(Rack::Lint::LintError). # message.must_match(/No Content-Type/) - [100, 101, 204, 205, 304].each do |status| + [100, 101, 204, 304].each do |status| lambda { Rack::Lint.new(lambda { |env| [status, {"Content-type" => "text/plain", "Content-length" => "0"}, []] @@ -280,7 +280,7 @@ describe Rack::Lint do end it "notice content-length errors" do - [100, 101, 204, 205, 304].each do |status| + [100, 101, 204, 304].each do |status| lambda { Rack::Lint.new(lambda { |env| [status, {"Content-length" => "0"}, []] diff --git a/test/spec_response.rb b/test/spec_response.rb index 2dd2c001..987199de 100644 --- a/test/spec_response.rb +++ b/test/spec_response.rb @@ -410,7 +410,7 @@ describe Rack::Response do res.body.must_be :closed? end - it "calls close on #body when 204, 205, or 304" do + it "calls close on #body when 204 or 304" do res = Rack::Response.new res.body = StringIO.new res.finish @@ -424,7 +424,7 @@ describe Rack::Response do res.body = StringIO.new res.status = 205 _, _, b = res.finish - res.body.must_be :closed? + res.body.wont_be :closed? b.wont_equal res.body res.body = StringIO.new -- EW -- --- You received this message because you are subscribed to the Google Groups "Rack Development" group. To unsubscribe from this group and stop receiving emails from it, send an email to rack-devel+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/d/optout.