Alex
Alex

Reputation: 1074

Does MaxHeaderBytes really works?

srv := &http.Server{
    Addr:           "127.0.0.1:8080",
    Handler:        r,
    MaxHeaderBytes: 1,
}
srv.ListenAndServe()

I made several requests by curl with custom headers, and app serving it, without any errors. What I am doing wrong?

Upvotes: 5

Views: 1567

Answers (1)

captncraig
captncraig

Reputation: 23118

Yes, it does, but they add a bit of padding to whatever you specify. In the code they add 4096 bytes to the limit for some reason.

Upvotes: 3

Related Questions