Code Monkey home page Code Monkey logo

Comments (12)

rhodee avatar rhodee commented on May 1, 2024 2

I @Fenny @erikdubbelboer I really appreciate your attention to my question. I believe we can close this issue because there is an alternative.

from fiber.

erikdubbelboer avatar erikdubbelboer commented on May 1, 2024 1

What will the trailers be used for? Is your response body so big that you can't wait with returning the initial headers until it is completely generated? I'm curious as I have never seen a use case for trailers before.

from fiber.

welcome avatar welcome commented on May 1, 2024

Thanks for opening your first issue here! 🎉 Be sure to follow the issue template!

from fiber.

Fenny avatar Fenny commented on May 1, 2024

@rhodee, I will leave this issue open for now. I will take a look at the RFC 7230 and see if we can help out to implement this in fasthttp.

You could ask @erikdubbelboer here if he could help implementing this, he is one of the core maintainers of fasthttp.

from fiber.

rhodee avatar rhodee commented on May 1, 2024

I will do just that @Fenny thank you for giving this a look!

from fiber.

erikdubbelboer avatar erikdubbelboer commented on May 1, 2024

@rhodee I'm guessing we are talking about receiving Trailers here or responding with Trailers? At least not sending them in an outgoing request right?

from fiber.

rhodee avatar rhodee commented on May 1, 2024

Hi @erikdubbelboer I am seeking an approach where I can define Trailer Headers, then set them after writing the chunk response. I think the semantics which best capture my intent are in this URL:

https://golang.org/pkg/net/http/#example_ResponseWriter_trailers

Does that make sense? If not I can try to explain further.

from fiber.

erikdubbelboer avatar erikdubbelboer commented on May 1, 2024

The problem I'm having with this is that fasthttp will always wait with sending a response until the handler function has returned. The only ways to send the response body after the handler has returned are SetBodyStream() and SetBodyStreamWriter(). These functions allow you to either specify an io.Reader to read the body from or write it yourself to an bufio.Writer. Neither of these give us the ability to allow you to add trailers after it all.

So to be able to send Trailers we'll need to add some form of API that allows you to set these after the handler has returned already.

In your use case, what are you using? SetBodyStream or SetBodyStreamWriter?

from fiber.

rhodee avatar rhodee commented on May 1, 2024

@erikdubbelboer this is a very helpful discussion. I am starting the fiber project from scratch (moving away from a gRPC implementation) and wanted to use Trailers (which I have in my gRPC implementation). So it is a clean slate 😄

from fiber.

rhodee avatar rhodee commented on May 1, 2024

Is your response body so big that you can't wait with returning the initial headers until it is completely generated?

They will not be. I use the trailer for timings or arbitrary messages, however it is trivial to meet my needs without Trailers.

from fiber.

Fenny avatar Fenny commented on May 1, 2024

Thanks @erikdubbelboer for jumping in 👍

from fiber.

pckhoi avatar pckhoi commented on May 1, 2024

In my case I'm using trailer headers to notify a down stream proxy to purge session since it is expensive to find out whether the session is done unless the body is completely generated. It is not a deal breaker to not support trailer but it still would be nice to have.

from fiber.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.