How to determine the size of the HTTP response header

by Daniel Pham
Published: Updated:

Today, I’ll share with you how to determine the size of the HTTP response header.

The problem I encountered

Last week one of my systems encountered the following error.

When a user send a resquest POST, a 502 error occurs.

I checked the log on the server, I received the following log.

2019/04/02 09:23:33 [error] 2962#2962: *56257144 upstream sent too big header while reading response header from upstream, client: xxx.xxx.xxx.xxx, server: domain.com, request: "POST /URI HTTP/2.0", upstream: "http://xxx.xxx.xxx.xxx:80/URI", host: "domain.com", referrer: "https://domain.com/"

You sympathize when I have to hide IP and domain and URI information in the log above.

Why did such an error occur?

The size of the HTTP response header

According to a Chromium document (this is Chrome’s open source), normally the size of the HTTP header will be about 700-800 bytes.

Uncompressed request and response headers. Request headers today vary in size from ~200 bytes to over 2KB. As applications use more cookies and user agents expand features, typical header sizes of 700-800 bytes is common.

You can read more about it at the following link.

How to determine the size of the HTTP response header

We now know that header are usually 1KB in size. I checked my system, I’m leaving it to be 16KB. So why is it still failed.

Log reported that the header is too large. Now I will find a way to determine the size of the header.

Follow an article that I refer to. There is a command that can be used to count the number of bytes of the header.

curl -s -w \%{size_header} -o /dev/null http://domain.com

Now I try to run with the Google website.

determine the HTTP response header of Google sites
Determine the HTTP response header of Google sites.

You see the results are 775, 773 and 781 bytes.

Note: Results may vary by browser.

You can get different response headers depending on the client, i.e. the browser can request capabilities (gzip compression, keep-alives, etc.) that affect the headers in the response, so you cannot assume testing with browser and curl will give you the exact same headers from the server.

Conclusion

This article, just a personal experience of mine. It may be somewhat useful. You often consider as a reference channel.

(This is an article from my old blog that has been inactive for a long time, I don’t want to throw it away so I will keep it and hope it helps someone).

0 0 votes
Article Rating

You may also like

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments

DevOps Lite is a personal blog specializing in technology with main topics about DevOps, DevSecOps, SRE and System Administrator. Articles are shared for free and contributed to the community.

SUPPORT US

FOLLOW US

Subscribe my Newsletter for new blog posts. Stay updated from your inbox!

© 2021-2024 DevOpsLite.com – All rights reserved.

Please write sources “DevOpsLite.com” when using articles from this website.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More

2
0
Would love your thoughts, please comment.x
()
x

Adblock Detected

Please support us by disabling your AdBlocker extension from your browsers for our website.