From mboxrd@z Thu Jan 1 00:00:00 1970 Delivered-To: chneukirchen@gmail.com Received: by 10.204.72.79 with SMTP id l15cs975767bkj; Mon, 17 Aug 2009 18:25:47 -0700 (PDT) Return-Path: Received-SPF: pass (google.com: domain of grbounce-ceibQwUAAAB4YPBqaDIjI2bFOCxyyh3G=chneukirchen=gmail.com@googlegroups.com designates 10.150.38.3 as permitted sender) client-ip=10.150.38.3; Authentication-Results: mr.google.com; spf=pass (google.com: domain of grbounce-ceibQwUAAAB4YPBqaDIjI2bFOCxyyh3G=chneukirchen=gmail.com@googlegroups.com designates 10.150.38.3 as permitted sender) smtp.mail=grbounce-ceibQwUAAAB4YPBqaDIjI2bFOCxyyh3G=chneukirchen=gmail.com@googlegroups.com; dkim=pass header.i=grbounce-ceibQwUAAAB4YPBqaDIjI2bFOCxyyh3G=chneukirchen=gmail.com@googlegroups.com Received: from mr.google.com ([10.150.38.3]) by 10.150.38.3 with SMTP id l3mr8723313ybl.3.1250558746453 (num_hops = 1); Mon, 17 Aug 2009 18:25:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=beta; h=domainkey-signature:received:received:x-sender:x-apparently-to :mime-version:received:date:in-reply-to:x-ip:references:user-agent :x-http-useragent:message-id:subject:from:to:content-type :content-transfer-encoding:reply-to:sender:precedence:x-google-loop :mailing-list:list-id:list-post:list-help:list-unsubscribe :x-beenthere-env:x-beenthere; bh=3MmryU2IPKTza/Zoo+TudyMVj965J5zFHvrXx+CcOes=; b=aepkxt1/2ot+2z0OvJ9bPxjortho/7Ud2Q7RLQ47pYp/mRg+dL/Q7eY0/r3GCaqadD vrfxg0OgOL8wIGnk4ILlcgQ1oPIYC2Zk9et8rPMF2bUwE6kh/lT5G5J98vpbyzq0pXhn g8boqDYE8NsIA4Gds07jJzhFFFTyfN8ScDyDY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlegroups.com; s=beta; h=x-sender:x-apparently-to:mime-version:date:in-reply-to:x-ip :references:user-agent:x-http-useragent:message-id:subject:from:to :content-type:content-transfer-encoding:reply-to:sender:precedence :x-google-loop:mailing-list:list-id:list-post:list-help :list-unsubscribe:x-beenthere-env:x-beenthere; b=pqazQehuio3FHWWm/oFyrgvtmGepAavY6brckLJRpW7BwU2YiIBQ/EHlpPjqJXhncL QXpLuwI9sK/gilXcPHNJtWbYIyo5kj9XxZtbUVMk577c1aAXi9+wSwG/AxGfyRVxmfgu R3V68bsE7LUcpJsj7g6kh/+GymhnvlBRjiTBo= Received: by 10.150.38.3 with SMTP id l3mr1345141ybl.3.1250558746383; Mon, 17 Aug 2009 18:25:46 -0700 (PDT) Received: by 10.177.38.34 with SMTP id q34gr1598yqj.0; Mon, 17 Aug 2009 18:25:41 -0700 (PDT) X-Sender: flyerhzm@gmail.com X-Apparently-To: rack-devel@googlegroups.com MIME-Version: 1.0 Received: by 10.101.29.29 with SMTP id g29mr1363037anj.18.1250558740201; Mon, 17 Aug 2009 18:25:40 -0700 (PDT) Date: Mon, 17 Aug 2009 18:25:40 -0700 (PDT) In-Reply-To: X-IP: 222.66.64.194 References: User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2,gzip(gfe),gzip(gfe) Message-ID: Subject: Re: response is empty From: flyerhzm To: Rack Development Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Reply-To: rack-devel@googlegroups.com Sender: rack-devel@googlegroups.com Precedence: bulk X-Google-Loop: groups Mailing-List: list rack-devel@googlegroups.com; contact rack-devel+owner@googlegroups.com List-Id: List-Post: List-Help: List-Unsubscribe: , X-BeenThere-Env: rack-devel@googlegroups.com X-BeenThere: rack-devel@googlegroups.com I think it's the problem of cache because if I disabled browser cache, the issue is fixed. Thanks On Aug 18, 5:41=A0am, Hongli Lai wrote: > On Aug 16, 5:19=A0pm, flyerhzm wrote: > > > > > I wrote a middleware in rails. The codes is like: > > > =A0 def initialize(app) > > =A0 =A0 @app =3D app > > =A0 end > > > =A0 def call(env) > > =A0 =A0 status, headers, response =3D @app.call(env) > > =A0 =A0 return [status, headers, response] if response.empty? > > =A0 =A0 # other logic codes > > =A0 end > > > When I refresh the page, the response will be empty. So I puts > > response.inspect, it's an empty array. Why? > > > So the other logic codes will not run, which need response.body. Is it > > some reason about cache? How can I make response always not empty? > > According to the Rack spec: > > "The Body must respond to each and must only yield String values. The > Body itself should not be an instance of String, as this will break in > Ruby 1.9." > > In other words: the Body is *not* a string, and is usually an Array of > string. When you call response.empty? you're actually checking whether > the response is an empty array, and returning just that. > > You should figure out how to do what you want with only an #each > method at your disposal.