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

Provide access to response TcpStream #2063

Closed
1 task done
YuzhongHuangCS opened this issue Jun 28, 2023 · 3 comments
Closed
1 task done

Provide access to response TcpStream #2063

YuzhongHuangCS opened this issue Jun 28, 2023 · 3 comments

Comments

@YuzhongHuangCS
Copy link

YuzhongHuangCS commented Jun 28, 2023

  • I have looked for existing issues (including closed) about this

Feature Request

Motivation

I am trying to use sendfile syscall to serve static file (tower issue link), which require access to response TcpStream.

Proposal

Currently, axum require request handler to return an object implement IntoResponse, and the framework will write it to response TcpStream.

I wish the axum could provide a way to access response TcpStream in request handler.

Alternatives

Use the current 2 copy implementation.

@davidpdrsn
Copy link
Member

Thats not compatible with axum being based on tower. tower::Service is pretty strictly async fn(Request) -> Response. Any other optimization would require that you interact with hyper, not axum.

@programatik29
Copy link
Contributor

This issue isn't related to axum.

You can try to control underlying stream by using a wrapper stream. Here is an example to do request header read timeouts. With more effort you can write custom stuff using same principle. You might get into fight with underlying hyper implementation about who is writing stuff so be careful.

@jplatte
Copy link
Member

jplatte commented Jun 29, 2023

Let's continue discussion on the tower-http issue, since axum clearly has nothing to do with the feature request.

@jplatte jplatte closed this as not planned Won't fix, can't repro, duplicate, stale Jun 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants