Rainbows! Rack HTTP server user/dev discussion
 help / color / mirror / code / Atom feed
From: Eric Wong <normalperson-rMlxZR9MS24@public.gmane.org>
To: Rainbows! list <rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org>
Subject: Re: streaming input for large requests
Date: Tue, 10 Aug 2010 16:25:27 -0700	[thread overview]
Message-ID: <20100810232527.GA14486@dcvr.yhbt.net> (raw)
In-Reply-To: <1281478992.8692.15.camel@dogen>

John Leach <john-6Yy1h0nn+LyySYScBAwQ8Q@public.gmane.org> wrote:
> Hi,
> 
> I'm looking to be able to get access to the request body as it is
> available on the socket, so I can process uploads on the fly, as they
> stream in.

Hi John,

Cool!  If you need some example code, you should check out upr,
http://upr.bogomips.org/  Sadly the demo machine is down, but the one
application I helped somebody write (on a private LAN somewhere) still
works well :)

There's also the test/examples in the Rainbows! source tree:

  t/sha1*.ru
  t/content-md5.ru

> But to be rewindable, I'm assuming they're being stored somewhere?  I'd
> like to be able to handle huge request bodies bit by bit without having
> them written to disk (or worse, stored in ram!).  Is there some way to
> do this?

Yes, we store uploads to an unlinked temporary file if the body is
larger than 112 Kbytes (this threshold was established by Mongrel back
in the day).

Rack currently requires rewindability, but this requirement will
most likely be optional in Rack 2.x, and we'll update our code
to match, then.

Meanwhile, you can either:

1. Write a module to disable writes to tmp for the Unicorn::TeeInput
   class (or monkey patch it) it.

2. Without loading Rack::Lint (or anything that wraps env["rack.input"]):
   Redirect the temporary file to /dev/null:

    input = env["rack.input"]
    if input.respond_to?(:tmp)
      tmp = input.tmp
      # StringIO is used for bodies <112K, can't reopen those
      tmp.respond_to?(:reopen) and tmp.reopen('/dev/null', 'wb')
    end

-- 
Eric Wong
_______________________________________________
Rainbows! mailing list - rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org
http://rubyforge.org/mailman/listinfo/rainbows-talk
Do not quote signatures (like this one) or top post when replying


  reply	other threads:[~2010-08-10 23:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-10 22:23 streaming input for large requests John Leach
2010-08-10 23:25 ` Eric Wong [this message]
     [not found]   ` <20100810232527.GA14486-yBiyF41qdooeIZ0/mPfg9Q@public.gmane.org>
2010-08-11  8:54     ` John Leach
2010-08-11 22:41     ` John Leach

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-all from there: mbox

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

  List information: https://yhbt.net/rainbows/

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

  git send-email \
    --in-reply-to=20100810232527.GA14486@dcvr.yhbt.net \
    --to=normalperson-rmlxzr9ms24@public.gmane.org \
    --cc=rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org \
    /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.
Code repositories for project(s) associated with this public inbox

	https://yhbt.net/rainbows.git/

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).