rack-devel archive mirror (unofficial) https://groups.google.com/group/rack-devel
 help / color / mirror / Atom feed
From: James Tucker <jftucker@gmail.com>
To: rack-devel@googlegroups.com
Subject: Re: rational for rewind()
Date: Thu, 17 Jul 2014 17:00:50 -0700	[thread overview]
Message-ID: <CABGa_T8uEEVB=yoekRL_7O=CzzHEw8Z1bfQN5wcnwOPLDkOnMw@mail.gmail.com> (raw)
In-Reply-To: <20140717234405.GA24893@dcvr.yhbt.net>

[-- Attachment #1: Type: text/plain, Size: 3064 bytes --]

On Thu, Jul 17, 2014 at 4:44 PM, Eric Wong <e@80x24.org> wrote:

> James Tucker <jftucker@gmail.com> wrote:
> > > Torsten Robitzki <Torsten@Robitzki.de> wrote:
> > > > Hello,
> > > > I'm implementing a C++ comet web server, that (tries) to implement
> rack
> > > to
> > > > adapt ruby applications. Currently I'm reading a body very naively
> put
> > > the
> > > > body into a ruby String and wrap it with a StringIO to provide the
> > > > rack.input for the implementation. As I'm going to use the server for
> > > > uploading images, I would like to implement a real, stream-like
> object to
> > > > circumvent the need to buffer the POST body before handing it to the
> > > > application.
> > >
> > > unicorn implements input like tee(1) doing lazy, rewindable buffering:
> > >         http://unicorn.bogomips.org/Unicorn/TeeInput.html
> >
> >
> > This is the approach I would take. I'm not sure if TeeInput supports it,
> > but for a generic server supporting websocket type use cases, I'd add a
> > discardable buffer API too, so you can "hijack" the input stream and
> > release any stale resources.
>
> I'm not completely sure what you mean[1], but both yahns and unicorn
> support rack.hijack.  TeeInput cannot read beyond the current HTTP
> request boundary, so I'm not sure there's anything that needs to change
> in the HTTP servers.
>

Right, I just mean "I own the socket now, throw away any buffers"

If a client pipelines non-HTTP data after a normal HTTP request, that
> would be a problem; but pipelining during a protocol change/negotiation
> seems wrong to begin with.
>

Yep, pipelining and upgrades with close semantics are evil. The correct
approach is to just discard any in-flight pipelined requests, and
technically they should have no side-effects due to the idempotence rule.
This is the important reason to strongly recommend using non-idempotent
HTTP methods for upgrade routes, as correct pipeline implementations should
serialize around those. All that said though, it's generally even more wise
to handle/split routing for these kinds of things at the load balancer
level, as they have totally different load semantics.


>
>
> [1] I've not tried rack.hijack with websockets, yet
>     I just (hopefully) implemented it according to the Rack spec.
>     GUI-oriented websocket things just do not interest me.
>

Totally fair :-)

I use SSE a lot more than websockets myself, as it's less complicated
across the whole stack.


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

-- 

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

[-- Attachment #2: Type: text/html, Size: 4668 bytes --]

  reply	other threads:[~2014-07-18  0:00 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-22 21:12 rational for rewind() Torsten Robitzki
2014-05-23 10:46 ` Magnus Holm
2014-05-24 12:35   ` Torsten Robitzki
2014-06-30 22:16     ` Daniel Doubrovkine
2014-07-15  4:30       ` James Tucker
2014-07-17 22:34 ` Eric Wong
2014-07-17 23:10   ` James Tucker
2014-07-17 23:44     ` Eric Wong
2014-07-18  0:00       ` James Tucker [this message]
2014-07-18  0:43         ` Eric Wong
2014-07-19  9:55     ` Torsten Robitzki

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='CABGa_T8uEEVB=yoekRL_7O=CzzHEw8Z1bfQN5wcnwOPLDkOnMw@mail.gmail.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).