Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Enable Pigora HttpServer Apps to stream Http Body. #499

Open
ednei opened this issue Dec 30, 2024 · 0 comments
Open

Enable Pigora HttpServer Apps to stream Http Body. #499

ednei opened this issue Dec 30, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@ednei
Copy link

ednei commented Dec 30, 2024

What is the problem your feature solves, or the need it fulfills?

Current implementation of ServeHttp has the Limitation that body cannot be streamed. This imposes a limitation for applications that need to stream a huge amount of data, or connect to other APIs that streams data.

Check: https://github.com/cloudflare/pingora/blob/main/pingora-core/src/apps/http_app.rs#L37

Describe the solution you'd like

I'm proposing make the HttpServer trait more flexible by introducing an associate type to representing the Body type which would allow HttpServer developer come up with the type that better suit its application:

pub trait HttpBody: Send + Sync {
    fn is_full_body(&self) -> bool;
    async fn next_chunk(&mut self) -> pingora::Result<Option<Bytes>>;
}

#[async_trait]
pub trait ServeHttp {
    type BODY: HttpBody;
    async fn response(&self, http_session: &mut ServerSession) -> Response<Self::BODY>;
}

I actually have this implemented on our project, and have some spare time to work on a PR.

@eaufavor eaufavor added the enhancement New feature or request label Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants