Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Streaming client request in api endpoints #2992

Closed
quentincaffeino opened this issue Dec 6, 2021 · 3 comments
Closed

Streaming client request in api endpoints #2992

quentincaffeino opened this issue Dec 6, 2021 · 3 comments

Comments

@quentincaffeino
Copy link

Describe the problem

Request streaming comes handy where you have very large requests and you don't want to clutter your ram with whole request and wait for it to fully upload, this way you can start processing it right away.

I found this example for nodejs http server which might give you a better idea of how this could be used:

http.createServer(function(r, s) {
    console.log(r.method, r.url, r.headers);
    var body = "";
    r.on('readable', function() {
        body += r.read(); // here instead of concatenation we could start processing data
    });
    r.on('end', function() {
        console.log(body);
        s.write("OK"); 
        s.end(); 
    });
}).listen(42646);

This could be useful for any non-static adapter.

This would also allow creating proxy endpoints where body is streamed to another fetch request (related: #2227). This is helpful because application could have handful of services and you might want to hide and open only one (in this case the sveltekit) which does some processing (maybe authentication) and then passes that request to another service.

Describe the proposed solution

Obvious one is to pass request stream to endpoint. But I'm not sure how it would work with current solution where you have for example FormData parsing which expects for request to be fully loaded and only then endpoint can start doing it's thing.

Alternatives considered

No response

Importance

would make my life easier

Additional Information

No response

@Conduitry
Copy link
Member

Duplicate of #1563.

@quentincaffeino
Copy link
Author

Duplicate of #1563.

@Conduitry Is it? Maybe I've missed something there but it seems that that issue is about streaming response where my is about streaming request.

@Rich-Harris
Copy link
Member

#3419 covers both requests and responses — closing

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants