http icon indicating copy to clipboard operation
http copied to clipboard

feat: add keep alive header

Open joaoprocopio opened this issue 2 months ago • 1 comments

i'm a huge fan of this library, everything about this library makes creating network services extremely pleasant.

as cited in the rfc 2616 "keep-alive" is a hop-by-hop header and shouldn't be forwarded to the upstream.
in my case i'm building a reverse proxy service and i need to prevent this headers from being cached and sent to the upstream, and it would be great to have this header that is needed to be treated inside the enum.

currently i'm just using this workaround.

const RFC_2616_HOP_BY_HOP_HEADERS: LazyLock<[HeaderName; 8]> = LazyLock::new(|| {
    [
        header::CONNECTION,
        header::HeaderName::from_static("keep-alive"),
        header::PROXY_AUTHENTICATE,
        header::PROXY_AUTHORIZATION,
        header::TE,
        header::TRAILER,
        header::TRANSFER_ENCODING,
        header::UPGRADE,
    ]
});

but this code could be simpler. (pretty irrelevant, but ok)

const RFC_2616_HOP_BY_HOP_HEADERS: &[HeaderName] = &[
        header::CONNECTION,
        header::KEEP_ALIVE,
        header::PROXY_AUTHENTICATE,
        header::PROXY_AUTHORIZATION,
        header::TE,
        header::TRAILER,
        header::TRANSFER_ENCODING,
        header::UPGRADE,
];

joaoprocopio avatar Oct 17 '25 22:10 joaoprocopio

hi, @seanmonstar!

I appreciate your work in this library, it's amazing!

do you think that this code could make it into the main branch?

joaoprocopio avatar Dec 05 '25 12:12 joaoprocopio