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: AS3215 2.6.0.0/16 X-Spam-Status: No, score=-3.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 Received: from mail-vk0-x23c.google.com (mail-vk0-x23c.google.com [IPv6:2607:f8b0:400c:c05::23c]) (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 3328620285 for ; Thu, 29 Jun 2017 02:19:19 +0000 (UTC) Received: by mail-vk0-x23c.google.com with SMTP id y70sf5991662vky.0 for ; Wed, 28 Jun 2017 19:19:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1498702758; cv=pass; d=google.com; s=arc-20160816; b=GkaEub/ed2ATaGsfgXOGkqa+GX/7JXC8hQr6CewsVB6W8kfGDQAAk49cPMXQlWaxGq HQwFgsCUa/GSVdhe5y6OZpGfzU1y9lH1qLk/8yYMlwb+Z19HsVSc96rsMmHOIdtlxhfH 6Yn1i6MlKeE15U/pRye8JdobwVNfqhakDKytY5OItNbXzyeGIgZTEmLVTiDowPMqyqG2 ohjMVZWJoQQZXkt2ZT18OwdZQASqeoRO/l0vJDlCKAaxMpGVi5iVitwygWzUXr80r4FV 6AY4p4Pnq/03iJOc7c5e6o2YQPAMZQlrjUMn1XKNjadYDF7CAH+Pswt+CV13ztgrwO6y xhpg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to:references:in-reply-to :message-id:date:subject:to:from:arc-authentication-results :arc-message-signature:mime-version:sender:dkim-signature :arc-authentication-results; bh=YoWuQgmygXn474aM0aFTyAIrudZgXJuqNAGmrli2Ot8=; b=IoOfuxr5ZRVoZv51JuxP5TAgYDOzwuZD9h4pR8miYeEo3tfJA1ABmObX05jqK+CWwN gGeO9TJGpbU8Oho80oDyvq4ogbZ7XnKC8eyfWcNVYeEW8/q2d9xqLW8+QS2qpkUyC/vE gPrlYtzRzfoWlZIhrksc1Y+/2x8s18uBPxDChX9Ykrpv16+R1pqr0tQ3wUnAm2jhCIeg +CrU/fGBW19FR9DofNOxuqmlEe8L0ylgZYIXxxZ7KElqy/UH9SnQpATgj15A9T2CQBU8 sa2qpW71nLDCkDaxN7WAejgZVBB/iMDk9oKEjs13LxP2Z769Up/qMBRSy5cDOnBGsV8e yVRw== ARC-Authentication-Results: i=2; 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:mime-version:from:to:subject:date:message-id:in-reply-to :references:x-original-sender:x-original-authentication-results :reply-to:precedence:mailing-list:list-id:list-post:list-help :list-archive:list-subscribe:list-unsubscribe; bh=YoWuQgmygXn474aM0aFTyAIrudZgXJuqNAGmrli2Ot8=; b=V5SSzCJFXCU5A3Qcu2bOGHm317JgRsLnXRf8nb7uWzifVBqRvBrasq+FmmM18ncY/X EttdDMoxWPGAIqjqrl4p4SLgqXS+3o0YBBPSmhcLiz+bhbAqp8ct965qhW8Qu3C+IYhz xe84Ox9kZnoNtsE1wbqQmrSR5okRJQawxac7d3dxVpnplKjyM1WAADqBFW3Lt13tUTqF 7AM5gLdOwJfLdjizpX+TAWsP7RTZLcUAhN/oeExFOuhDN1f0HBvUJ5Q97UAHJCqjrjsD s/Lt8DcIxwVBAXDJ8SHz+56hTwES6Tukuv+VX1Kctv8EKradKC6wpILQbGIT/5vtWqO8 iNsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:mime-version:from:to:subject:date :message-id:in-reply-to:references: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=YoWuQgmygXn474aM0aFTyAIrudZgXJuqNAGmrli2Ot8=; b=QMv9uxT1z9/IQHcNgyZPsDH5ThZQMsWp8BU69clQFJcmKzNjzYb0wAkzOFOtzK/H3s DCMve1+BfYPmp6Ue6C7ymC5ATGATau8MY5zydIPsMliJHHQhbP32sTFJ5vWBZ+u29z9W LFw2oJ41oS+OwjD6ynHcvINBn/SyWbXjyrPWIdLMkZFDjtWJ4acMCI9RdtaTYsjDgeAW TebWaTZCGBCYNEHdgl9Nd3p9/0UD9ByXSHJs7o/e0ph5fWKw0lkfVKlOA3KE2ghZHb+M UjjDObGbvTJJLoUqUeYfbIEqR16/DB6j1rOphQlBZFfpT5z0g3cl6pJV5zT5VnCBji7u bVOw== Sender: rack-devel@googlegroups.com X-Gm-Message-State: AKS2vOzGEzPI3RZO3f9CVunzdHqRp5dULrIzT4Pcus/mI9Dcw7c/NgqT AFF2UO1FjO92AA== X-Received: by 10.36.23.151 with SMTP id 145mr272667ith.7.1498702758067; Wed, 28 Jun 2017 19:19:18 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: rack-devel@googlegroups.com Received: by 10.36.16.148 with SMTP id 142ls3607773ity.18.gmail; Wed, 28 Jun 2017 19:19:17 -0700 (PDT) X-Received: by 10.99.171.12 with SMTP id p12mr7906590pgf.99.1498702757580; Wed, 28 Jun 2017 19:19:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498702757; cv=none; d=google.com; s=arc-20160816; b=WP29nrb9rUGTi8Xi3A0F2DLAaVV6uX45y9ChnWLklC6ACSU70DsgIJISYv/zGmi3AK UQORZbNhuS2kS/qlDnOOnYfhdaux8ryoqLCVwF6Guw9qY77eBFptcri5KYXseJLrYtjH shkcY6C/WM5ikz0bd1w0bxyvc7kSVOi4JV2vljRnVMeza29RWaigyPBjM+HMxhJ2t3yi hNJxO41Ecql3OD/S+aPF89lPH6/33mPNiWBBC9Um+QejgKDtBvbmt048CuRoxJAurQI2 4IV3Pv90ZIjpLHJpWAu1Xognz7a1F0Ub/vGyvruuSbA7owGnMyb2pP67Oc2terwML5eO 6N7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from :arc-authentication-results; bh=4B7hW1TXR8QvjsGauskyGD0PFBnl1JC+oQTMDZ3Oa1I=; b=LKRdAKdcRK8A/uu5IZmsWb/sRqU/wy1mgrWGsHRirMl0ZFeH7y79HJ1gPpPr9vn5wy eyOVfdj1wtJzrmCcq3z8XDE9tzA4dFkpZzT/Uec1GqQprU4j2Ft6QKZT1WutU18+A0Mh MsPfVIsOOrBdCg+zw390W5xrYcCsFNOBLZV1UPEuYCYQZhl+Z2qSpHODY54XtsV5b64S 0VYTKdx0U/JGkX90Tv6+d9o2xlw4DvIQv8UNdoVG4SF+EgJh1XlDUW2E/y+Qm6p/WFpU oId0CJCr1+0omS0laJIAIDQnc9Oshc1fciILH3CssRY9AnXk3LPuNTiwZdTu8NxenbXw Pn/g== ARC-Authentication-Results: i=1; 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 Received: from dcvr.yhbt.net (dcvr.yhbt.net. [64.71.152.64]) by gmr-mx.google.com with ESMTPS id p74si64550pfj.10.2017.06.28.19.19.17 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Jun 2017 19:19:17 -0700 (PDT) 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 720DA20285 for ; Thu, 29 Jun 2017 02:19:15 +0000 (UTC) From: Eric Wong To: rack-devel@googlegroups.com Subject: [PATCH 1/5] deflater: rely on frozen_string_literal Date: Thu, 29 Jun 2017 02:19:11 +0000 Message-Id: <20170629021915.22517-2-e@80x24.org> In-Reply-To: <20170629021915.22517-1-e@80x24.org> References: <20170629021915.22517-1-e@80x24.org> 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 Content-Type: text/plain; charset="UTF-8" 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: , This improves readability of our code and can allow us to generate less garbage in Ruby 2.3+ for places where we didn't already use constants. We can also avoid the old constant lookups (and associated inline cache overhead) this way. --- lib/rack/deflater.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/rack/deflater.rb b/lib/rack/deflater.rb index 46d5b20..9b798ba 100644 --- a/lib/rack/deflater.rb +++ b/lib/rack/deflater.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "zlib" require "time" # for Time.httpdate require 'rack/utils' @@ -52,7 +53,7 @@ module Rack case encoding when "gzip" headers['Content-Encoding'] = "gzip" - headers.delete(CONTENT_LENGTH) + headers.delete('Content-Length') mtime = headers.key?("Last-Modified") ? Time.httpdate(headers["Last-Modified"]) : Time.now [status, headers, GzipStream.new(body, mtime)] @@ -61,7 +62,7 @@ module Rack when nil message = "An acceptable encoding for the requested resource #{request.fullpath} could not be found." bp = Rack::BodyProxy.new([message]) { body.close if body.respond_to?(:close) } - [406, {CONTENT_TYPE => "text/plain", CONTENT_LENGTH => message.length.to_s}, bp] + [406, {'Content-Type' => "text/plain", 'Content-Length' => message.length.to_s}, bp] end end @@ -102,13 +103,13 @@ module Rack # Skip compressing empty entity body responses and responses with # no-transform set. if Utils::STATUS_WITH_NO_ENTITY_BODY.include?(status) || - headers[CACHE_CONTROL].to_s =~ /\bno-transform\b/ || + headers['Cache-Control'].to_s =~ /\bno-transform\b/ || (headers['Content-Encoding'] && headers['Content-Encoding'] !~ /\bidentity\b/) return false end # Skip if @compressible_types are given and does not include request's content type - return false if @compressible_types && !(headers.has_key?(CONTENT_TYPE) && @compressible_types.include?(headers[CONTENT_TYPE][/[^;]*/])) + return false if @compressible_types && !(headers.has_key?('Content-Type') && @compressible_types.include?(headers['Content-Type'][/[^;]*/])) # Skip if @condition lambda is given and evaluates to false return false if @condition && !@condition.call(env, 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.