Skip to content

Configure Max Header Count #3305

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

Open
1 task done
Adam-Alj opened this issue Apr 4, 2025 · 5 comments
Open
1 task done

Configure Max Header Count #3305

Adam-Alj opened this issue Apr 4, 2025 · 5 comments

Comments

@Adam-Alj
Copy link

Adam-Alj commented Apr 4, 2025

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

Feature Request

Motivation

Working on a large enterprise system and using axum for one of our services.
The system, for better or worse, passes around a large number of headers, over the default number of 100 headers as declared in hyper.

The hyper library exposes a function to override this default value, however this is not exposed through axum.

Proposal

Expose this configuration through axum configuration settings.

Would you be receptive to a pull request to expose this as a config option?

Alternatives

We maintain a patched fork to set this in serve.rs, but would rather have this configurability present in the unpatched library.

We considered using plain hyper, which is suggested in the axum docs, however such a relatively innocuous http-server configuration seems valid for inclusion in axum configuration.

@mladedav
Copy link
Collaborator

mladedav commented Apr 5, 2025

There are more hyper configurations that should be available so I don't think we should go with exposing this one option but rather find a way to let users have more control over the underlying hyper connections.

You might also want to look at axum-server, I believe you can set things like these through that but it's another (3rd party) dependency.

@jplatte
Copy link
Member

jplatte commented Apr 5, 2025

I don't think there is a way to give people access to all the hyper settings at once without making hyper-util a public dependency.

Not sure what the best solution is for this. At my workplace we have also vendored axum::serve for some setting (I forget which one). It's probably not actually that bad to add a couple of extra settings as people ask for them?

@mladedav
Copy link
Collaborator

mladedav commented Apr 5, 2025

I worry it'll become a whack-a-mole with different configs to be exposed. But sure, we can expose some settings.

I don't see a problem with making hyper-util public though. I don't feel like it's that unstable or anything.

@Adam-Alj
Copy link
Author

Adam-Alj commented Apr 9, 2025

Great to hear that there's interest and openness to this. We'll work on getting a PR up.

@Sakthi-Maan
Copy link

Thanks everyone for the discussion.

In the meantime, while waiting for this feature to potentially be included in Axum core, I’ve used the axum-server crate to successfully override the default Hyper header limit. It gives access to hyper::server::conn::Http settings like http1_max_headers.

Here's a minimal example of how to raise the limit to 512:

axum_server::bind(addr)
.http_builder(Http::new().http1_max_headers(512))
.serve(app.into_make_service())
.await
.unwrap();

This could serve as a temporary solution for anyone needing to bypass the default 100 header limit. That said, I’d love to see a clean abstraction for this within Axum itself, especially since header limits and other Hyper-level configs are common in enterprise setups. Happy to help draft a potential API design if needed!

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