Hi Jay,

On Mon, 4 Sep 2017 16:23:43 +0100, Jay McCarthy
<jay.mccar...@gmail.com> wrote:


>On Fri, Sep 1, 2017 at 10:57 PM, George Neuner <gneun...@comcast.net> wrote:
>
>> Is there a way in the web-server to stream incoming data?  Or maybe to
>> get at the request before the (multipart) form data is read in?
>


>There is not a way to do this. Should there be? Could there be?
>
>The relevant code is here:
>
>https://github.com/racket/web-server/blob/master/web-server-lib/web-server/http/request.rkt#L52
>
>and
>
>https://github.com/racket/web-server/blob/master/web-server-lib/web-server/http/request.rkt#L219
>
>It would be challenging to do this. Suppose that a request struct
>contained the input port (the obvious thing to do.) The problem is
>that the servlet MUST consume it all before the Web server can look
>for the next HTTP request (because in 1.1 there's multiple per
>connection.) So what if the servlet doesn't? Do we detect when it
>loses the reference and then slurp it up and keep going on the
>connection? It is currently allowed to store a request in a global
>data-structure for later, for instance.

Hmmm.  Does 1.1 allow queuing requests, or only keeping the connection
open between requests?  If the latter, then it should be safe to just
drain the connection.


>Let's suppose we ignore that problem and only enable this when
>#:connection-close? is true and there's only one request per
>connection... then there's a backwards compatibility problem because a
>request already contains the raw-bytes. We could delay them, but
>getting them will require having a copy of the result of reading the
>input port, which is exactly what you are trying to avoid.

This I understand - unfortunately. <frown>


>I think we're stuck as far as the Web server's defaults go (but maybe
>you can think of something.) I think the best thing to do is to add
>the right knob to make-read-request and make it easy to configure a
>special dispatcher that does what you want and use URI case matching
>to get into the right code path for you. (I.e. Have your server
>default to the new behavior and then switch to the old behavior when
>you are going to do a normal non-streaming read before handing the
>request to your servlet.)

I'll take a look at it.  Thanks for the exposition!

George

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to