From mboxrd@z Thu Jan 1 00:00:00 1970 Delivered-To: chneukirchen@gmail.com Received: by 10.141.43.5 with SMTP id v5cs99411rvj; Mon, 8 Feb 2010 10:44:50 -0800 (PST) Received-SPF: pass (google.com: domain of 3oFtwSwELCrcoqljXvhl.ZljoXZh-absbidlldibdolrmp.Zlj@groups.bounces.google.com designates 10.220.123.215 as permitted sender) client-ip=10.220.123.215; Authentication-Results: mr.google.com; spf=pass (google.com: domain of 3oFtwSwELCrcoqljXvhl.ZljoXZh-absbidlldibdolrmp.Zlj@groups.bounces.google.com designates 10.220.123.215 as permitted sender) smtp.mail=3oFtwSwELCrcoqljXvhl.ZljoXZh-absbidlldibdolrmp.Zlj@groups.bounces.google.com; dkim=pass header.i=3oFtwSwELCrcoqljXvhl.ZljoXZh-absbidlldibdolrmp.Zlj@groups.bounces.google.com Received: from mr.google.com ([10.220.123.215]) by 10.220.123.215 with SMTP id q23mr607678vcr.59.1265654689749 (num_hops = 1); Mon, 08 Feb 2010 10:44:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=beta; h=domainkey-signature:received:x-beenthere:received:received:received :received:received-spf:received:mime-version:sender:received :in-reply-to:references:date:message-id:subject:from:to :x-original-authentication-results:x-original-sender:reply-to :precedence:mailing-list:list-id:list-post:list-help:list-archive :x-thread-url:x-message-url:list-subscribe:list-unsubscribe :content-type; bh=HuzHW3pPUkvHTPwRmPPTo5v7DIf4Jc579oRvl/MwuCE=; b=FP5Fls2HEmNF/r1kDfZy8TMhIBQEMmtc/mfuo9PE0m3rMbj9MtXzc47sptyMUbvxJg aUS+64c7ntybPjTOvmbBVJaiCWnjdMY3K7tUpBoukinPIgrjJeU4F1BdEFJbUfTIhV4A oMa9nskWVHVLAIAgHzUTxZFzBGz5ctEGpjmtI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlegroups.com; s=beta; h=x-beenthere:received-spf:mime-version:sender:in-reply-to:references :date:message-id:subject:from:to:x-original-authentication-results :x-original-sender:reply-to:precedence:mailing-list:list-id :list-post:list-help:list-archive:x-thread-url:x-message-url :list-subscribe:list-unsubscribe:content-type; b=eadO55v/lRGBU1MuDkA+ENwf/q4G5CYhxCe+t7HSoSZ9DZfmesqkPONOFSwA4GT+Ce QHgemF+YBKe7E1mbsueO1gupCTMd+UZAEPXtfmG3dQFazAmrFp9o+QHgNVXliW0rmmpo PIhqzFTZAK+Zs0D24z783vrYwz8Y+A5epvsDo= Received: by 10.220.123.215 with SMTP id q23mr59119vcr.59.1265654688507; Mon, 08 Feb 2010 10:44:48 -0800 (PST) X-BeenThere: rack-devel@googlegroups.com Received: by 10.220.87.136 with SMTP id w8ls1105679vcl.0.p; Mon, 08 Feb 2010 10:44:47 -0800 (PST) Received: by 10.220.114.76 with SMTP id d12mr1311230vcq.20.1265654687061; Mon, 08 Feb 2010 10:44:47 -0800 (PST) Received: by 10.220.114.76 with SMTP id d12mr1311226vcq.20.1265654687037; Mon, 08 Feb 2010 10:44:47 -0800 (PST) Return-Path: Received: from mail-qy0-f202.google.com (mail-qy0-f202.google.com [209.85.221.202]) by gmr-mx.google.com with ESMTP id 27si4093013vws.7.2010.02.08.10.44.45; Mon, 08 Feb 2010 10:44:46 -0800 (PST) Received-SPF: pass (google.com: domain of rtomayko@gmail.com designates 209.85.221.202 as permitted sender) client-ip=209.85.221.202; Received: by mail-qy0-f202.google.com with SMTP id 40so3472462qyk.14 for ; Mon, 08 Feb 2010 10:44:45 -0800 (PST) MIME-Version: 1.0 Sender: rack-devel@googlegroups.com Received: by 10.224.62.35 with SMTP id v35mr2620378qah.166.1265654685409; Mon, 08 Feb 2010 10:44:45 -0800 (PST) In-Reply-To: <1264316104.1391.389.camel@alex-desktop> References: <1264316104.1391.389.camel@alex-desktop> Date: Mon, 8 Feb 2010 10:44:45 -0800 Message-ID: Subject: Re: Bug in HeaderHash From: Ryan Tomayko To: rack-devel@googlegroups.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of rtomayko@gmail.com designates 209.85.221.202 as permitted sender) smtp.mail=rtomayko@gmail.com; dkim=pass (test mode) header.i=@gmail.com X-Original-Sender: r@tomayko.com Reply-To: rack-devel@googlegroups.com Precedence: list Mailing-list: list rack-devel@googlegroups.com; contact rack-devel+owners@googlegroups.com List-ID: List-Post: , List-Help: , List-Archive: X-Thread-Url: http://groups.google.com/group/rack-devel/t/cb0548dfe7a70702 X-Message-Url: http://groups.google.com/group/rack-devel/msg/ddbc6c69368618a5 List-Subscribe: , List-Unsubscribe: , Content-Type: text/plain; charset=UTF-8 On Sat, Jan 23, 2010 at 10:55 PM, Alex Beregszaszi wrote: > Hi, > > Currently the included Rack::Deflater will fail (and surely other > modules can fail too) if gzip encoding is used and some other conditions > are met. Like the ConditionalGet plugin is run first. > > The appropriate code in Deflater: > > mtime = headers.key?("Last-Modified") ? > Time.httpdate(headers("Last-Modified"]) : Time.now > > Time.httpdate(nil) will cause an Exception. Based on the above code, > that shouldn't happen, but it does. > > Turned out that in the ConditionalGet.modified_since function > headers['Last-Modified'] is read and that causes the error. > > The real problem lies in HeaderHash.[]: > > super(@names[k] ||= @names[k.downcase]) > > In the above situation where @names is a Hash, @names[k] (and > @names[k.downcase]) will return nil first and then a Hash entry will be > created in @names and set to nil. The above code will work fine > whatsoever, but afterwards HeaderHash.include? will erroneously report > that header key as present. > > The attached patch fixes this issue. Note, you can still set a http > header to nil after the patch (the []= isn't involved). > > Simple way to reproduce the error: > headers = Utils::HeaderHash.new(headers) > headers['wont-be-there'] > puts "error" if headers.include?('wont-be-there') Applied and pushed to master in f6f3c60. Thanks, Ryan