From mboxrd@z Thu Jan 1 00:00:00 1970 Delivered-To: chneukirchen@gmail.com Received: by 10.25.214.169 with SMTP id p41csp91739lfi; Mon, 21 Sep 2015 14:50:41 -0700 (PDT) X-Received: by 10.55.217.84 with SMTP id u81mr25661108qki.76.1442872241262; Mon, 21 Sep 2015 14:50:41 -0700 (PDT) Return-Path: Received: from mail-qk0-x237.google.com (mail-qk0-x237.google.com. [2607:f8b0:400d:c09::237]) by mx.google.com with ESMTPS id q7si21488403qki.84.2015.09.21.14.50.40 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Sep 2015 14:50:41 -0700 (PDT) Received-SPF: pass (google.com: domain of rack-devel+bncBDI5L5VXVAHBBL7XQGYAKGQE5B36LSQ@googlegroups.com designates 2607:f8b0:400d:c09::237 as permitted sender) client-ip=2607:f8b0:400d:c09::237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of rack-devel+bncBDI5L5VXVAHBBL7XQGYAKGQE5B36LSQ@googlegroups.com designates 2607:f8b0:400d:c09::237 as permitted sender) smtp.mailfrom=rack-devel+bncBDI5L5VXVAHBBL7XQGYAKGQE5B36LSQ@googlegroups.com; dkim=pass header.i=@googlegroups.com Received: by mail-qk0-x237.google.com with SMTP id j65sf17900779qkf.0; Mon, 21 Sep 2015 14:50:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20120806; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent :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=hr3aV5gw6HzDHFKwDgL+GxIVSiOVzwSRunvF6JHghkM=; b=xkZFGJaO8ga3zfhWUl3VUFi9z5X44iHDzMUibp8PfYGHTiHOznwe2PrRRv2lhVOkoC dru0kBPhRd8J7jSi3EX3ngPhhhVT8BlNa0AINOKhCotG4BFjiQGqJuL8tVbVQjCutlyn ArLJub4vqTYhUz3okF2hhA7mjxxCvwh9ohwdiUwVwHnJ49MldJCMGac46yNRS9Ed4YqG zHdIl1mOt6YfUFvYHTDf+FXiRpg2M3zalFMdSqtfVsSfgpJX0faF2hWHRG1XY2/8nkWG BkYzyXQBHiUMeEWgi7kXH8821yJoH/s/i3BMWWZkCaExFw47VpzHVAvh5HrQJV0g2CgZ uBfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-type:content-disposition :in-reply-to:user-agent: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=hr3aV5gw6HzDHFKwDgL+GxIVSiOVzwSRunvF6JHghkM=; b=CiqZ0aWGZn9elNtIeIGfDTEup19xq7i6pnh1xa0PjYef33ewaaM5CBTGDii1xK9y26 2ckTZmZbXFYmh/mKqXfhvszoGiP2T4CCWOx/G7PS/0rj2Wj8KovCZOmHGb1FqWLJoBWN uNSnqWR6zOIrz+GDp8z6/xcOYtWQhrUe+BfWkNcwk7q3vj4CL6J0PELubjc/19DJFhFw 42Q6B6T/AXHDo69SXcAua/Dkoo7mJXY/5PSOUfvIrbjX5zrCL9JKyj3Ra7Q1e8aRwPb5 S8+GduHiYPRunLH9VBhKcfSS7bTZ2uFB30h5ogH3z1mz/vdY8p/50tIfevoC5Ds2MYAa D9Eg== X-Received: by 10.140.101.108 with SMTP id t99mr151703qge.27.1442872240252; Mon, 21 Sep 2015 14:50:40 -0700 (PDT) X-BeenThere: rack-devel@googlegroups.com Received: by 10.140.98.35 with SMTP id n32ls2470122qge.78.gmail; Mon, 21 Sep 2015 14:50:39 -0700 (PDT) X-Received: by 10.13.216.77 with SMTP id a74mr20559409ywe.9.1442872238991; Mon, 21 Sep 2015 14:50:38 -0700 (PDT) Received: from mail-pa0-f45.google.com (mail-pa0-f45.google.com. [209.85.220.45]) by gmr-mx.google.com with ESMTPS id wl2si3188791pab.1.2015.09.21.14.50.38 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Sep 2015 14:50:38 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.45 is neither permitted nor denied by best guess record for domain of aaron@tenderlovemaking.com) client-ip=209.85.220.45; Received: by padbj2 with SMTP id bj2so2604520pad.3 for ; Mon, 21 Sep 2015 14:50:38 -0700 (PDT) X-Gm-Message-State: ALoCoQkRvSDYwbZk45jqpnkpTr3RlsUT4v4kDCos7pzm3xT1zWsArFUkUxl+VVb5m9DqS8Rm8u5N X-Received: by 10.68.194.73 with SMTP id hu9mr27922745pbc.146.1442872238751; Mon, 21 Sep 2015 14:50:38 -0700 (PDT) Received: from TC.local (c-24-56-254-189.customer.broadstripe.net. [24.56.254.189]) by smtp.gmail.com with ESMTPSA id kw10sm198438pbc.25.2015.09.21.14.50.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Sep 2015 14:50:38 -0700 (PDT) Sender: rack-devel@googlegroups.com Date: Mon, 21 Sep 2015 14:50:34 -0700 From: Aaron Patterson To: Eric Wong Cc: rack-devel@googlegroups.com Subject: Re: [PATCH] deflater: always finish zlib stream before closing Message-ID: <20150921215034.GA90032@TC.local> References: <20150921211615.GA8804@dcvr.yhbt.net> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="W/nzBZO5zC0uMSeA" Content-Disposition: inline In-Reply-To: <20150921211615.GA8804@dcvr.yhbt.net> User-Agent: Mutt/1.5.23 (2014-03-12) X-Original-Sender: aaron@tenderlovemaking.com X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 209.85.220.45 is neither permitted nor denied by best guess record for domain of aaron@tenderlovemaking.com) smtp.mailfrom=aaron@tenderlovemaking.com Reply-To: rack-devel@googlegroups.com Precedence: list Mailing-list: list rack-devel@googlegroups.com; contact rack-devel+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: rack-devel@googlegroups.com X-Google-Group-Id: 486215384060 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , --W/nzBZO5zC0uMSeA Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Applied, thanks! On Mon, Sep 21, 2015 at 09:16:15PM +0000, Eric Wong wrote: > This helps avoid Zlib::DataError when a client disconnects on > the server while the server is writing the response. > > This fixes the following backtraces on my server: > > data error (Zlib::DataError) > rack/deflater.rb:124:in `close' > rack/deflater.rb:124:in `ensure in each' > rack/deflater.rb:124:in `each' > rack/chunked.rb:23:in `each' > ... > --- > If you prefer: git pull git://80x24.org/rack zlib-disco > > The following changes since commit c28f271d0c91f45e13bfa8f07bed445ef91f41de: > > Merge pull request #942 from keepcosmos/remove-fulltest-guide (2015-09-08 07:45:02 -0700) > > are available in the git repository at: > > git://80x24.org/rack zlib-disco > > for you to fetch changes up to f769efe714f5b8b417e0440ce05f8b4e4b504c57: > > deflater: always finish zlib stream before closing (2015-09-21 21:11:50 +0000) > > ---------------------------------------------------------------- > Eric Wong (1): > deflater: always finish zlib stream before closing > > lib/rack/deflater.rb | 3 ++- > test/spec_deflater.rb | 25 +++++++++++++++++++++++++ > 2 files changed, 27 insertions(+), 1 deletion(-) > > diff --git a/lib/rack/deflater.rb b/lib/rack/deflater.rb > index 19dc755..62a1124 100644 > --- a/lib/rack/deflater.rb > +++ b/lib/rack/deflater.rb > @@ -118,8 +118,9 @@ module Rack > def each > deflator = ::Zlib::Deflate.new(*DEFLATE_ARGS) > @body.each { |part| yield deflator.deflate(part, Zlib::SYNC_FLUSH) } > - yield deflator.finish > + yield fin = deflator.finish > ensure > + deflator.finish unless fin > deflator.close > end > > diff --git a/test/spec_deflater.rb b/test/spec_deflater.rb > index 2c7a428..ba7ec5d 100644 > --- a/test/spec_deflater.rb > +++ b/test/spec_deflater.rb > @@ -114,6 +114,31 @@ describe Rack::Deflater do > end > end > > + it 'does not raise when a client aborts reading' do > + app_body = Object.new > + class << app_body; def each; yield('foo'); yield('bar'); end; end > + opts = { 'skip_body_verify' => true } > + verify(200, app_body, 'deflate', opts) do |status, headers, body| > + headers.must_equal({ > + 'Content-Encoding' => 'deflate', > + 'Vary' => 'Accept-Encoding', > + 'Content-Type' => 'text/plain' > + }) > + > + buf = [] > + inflater = Zlib::Inflate.new(-Zlib::MAX_WBITS) > + FakeDisconnect = Class.new(RuntimeError) > + assert_raises(FakeDisconnect, "not Zlib::DataError not raised") do > + body.each do |part| > + buf << inflater.inflate(part) > + raise FakeDisconnect > + end > + end > + assert_raises(Zlib::BufError) { inflater.finish } > + buf.must_equal(%w(foo)) > + end > + end > + > # TODO: This is really just a special case of the above... > it 'be able to deflate String bodies' do > verify(200, 'Hello world!', 'deflate') do |status, headers, body| > -- > 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. -- Aaron Patterson http://tenderlovemaking.com/ -- --- 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. --W/nzBZO5zC0uMSeA Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- iQEcBAEBAgAGBQJWAHuqAAoJEJUxcLy0/6/GBQEH/ihNc6fNcA0zNo/lgs9dTxFb JpSDe8lWv8tTeWcoFR7QugiqMYizNllwMkvFEPo7tFVmtJ13F0HUnlFDs+PpzVMx 5+A7ISsOthrz8SXR9FvGD7uehe/ATd0vT92HXEXw40j0AukZQiPKRYx+YIlXwsMs /SxK2NI+/WZQZdq3MUT8teIN4BIJx4qS93b1Xj+Xpgv8T1rvA3aCo0AUuQwwxcp0 wyJ5CCmfRXGIetd2LYxl+fRK4zTX82ZFWOhUqw8S4Pg2q/IN//PMtl0xvwLU96UG gezHBq/j4+QRdIsplfhot7Vn46TuVlMLT4/4ZHeU+KyO61B7VMpvasVRq0vkvZA= =OxUY -----END PGP SIGNATURE----- --W/nzBZO5zC0uMSeA--