Hi everyone, is there a way to stream body payload...
# http4k
t
Hi everyone, is there a way to stream body payload on the server side, or at least restrict its size to a same limit without reading it into memory?
d
is this from the serverside or from the clientside?
t
server side, we want to protect the server from filling memory
d
ok - which server are you using?
t
at the moment just
SunHttp
is this server dependent?
we’ll deploy to AWS Lambda
d
well not really - but you can, for instance, configure undertow to only accept a certain size of request.
t
can it be done in http4k as well, or do we need to configure it on the server?
d
anyway, you can get the stream from incoming request
request.body.stream
t
We saw it’s already closed when we try to access it in the handler. Is there a size limit of when the request won’t be read immediately?
Thank you for your time!
d
np 🙂
SunHttp definitely does support request streaming. We've even got a test to prove it..
SunHttpStreamingTest
t
ok great, thank you very much!
I’ll look into the test 🙂
d
one danger is that you may be accessing the payload before attempting to read the stream.
doing that WILL pull the contents of the stream into memory -
this often happens when you debug the input using a filter
(we've been caught by it several times!)
t
yes, it was the debugger !
we moved the breakpoint and it started working 🙂
thank you again
d
😂