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.

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.

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

Jay


On Fri, Sep 1, 2017 at 10:57 PM, George Neuner <gneun...@comcast.net> wrote:
> On Fri, 1 Sep 2017 14:38:21 -0400, Neil Van Dyke
> <n...@neilvandyke.org> wrote:
>
>> ... *except when a GC cycle kicks in*.
>
> Speaking of web servers and GC ...
>
>
> I have a http web-server application that needs to be able to up/down
> load fairly large files.  The application is somewhat memory
> constrained, and I'd like to handle these large data transfers in
> chunks using (relatively) small buffers.
>
> Outgoing is not [much of] a problem because the client TCP connection
> is available in response/output ... but with incoming data, the
> web-server framework has slurped in everything before my code even
> runs.
>
> 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?
>
> 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.



-- 
-=[     Jay McCarthy               http://jeapostrophe.github.io    ]=-
-=[ Associate Professor        PLT @ CS @ UMass Lowell     ]=-
-=[ Moses 1:33: And worlds without number have I created; ]=-

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