rack-devel archive mirror (unofficial) https://groups.google.com/group/rack-devel
 help / color / mirror / Atom feed
From: flyerhzm <flyerhzm@gmail.com>
To: Rack Development <rack-devel@googlegroups.com>
Subject: Re: response is empty
Date: Mon, 17 Aug 2009 18:25:40 -0700 (PDT)	[thread overview]
Message-ID: <a5c93564-6f15-4556-8cbc-dc3743857b5c@24g2000yqm.googlegroups.com> (raw)
In-Reply-To: <b1fbc0ec-80b8-4b3a-b975-410aa6279eeb@j21g2000yqe.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 am, Hongli Lai <hon...@phusion.nl> wrote:
> On Aug 16, 5:19 pm, flyerhzm <flyer...@gmail.com> wrote:
>
>
>
> > I wrote a middleware in rails. The codes is like:
>
> >   def initialize(app)
> >     @app = app
> >   end
>
> >   def call(env)
> >     status, headers, response = @app.call(env)
> >     return [status, headers, response] if response.empty?
> >     # other logic codes
> >   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.

      reply	other threads:[~2009-08-18  1:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-16 15:19 response is empty flyerhzm
2009-08-17 21:41 ` Hongli Lai
2009-08-18  1:25   ` flyerhzm [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://groups.google.com/group/rack-devel

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a5c93564-6f15-4556-8cbc-dc3743857b5c@24g2000yqm.googlegroups.com \
    --to=rack-devel@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).