How to determine the size of the HTTP response header

Share this post to your friends !
  • 20
    Shares

How to determine the size of the HTTP response header
5 (100%) 1 vote[s]

WriteBash - 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.

how-to-determine-the-size-of-the-http-response-header How to determine the size of the HTTP response header
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.

If you liked this article, then please subscribe to our YouTube Channel for more video tutorials. You can also find us on Twitter and Facebook.


Share this post to your friends !
  • 20
    Shares
If you appreciate what we share in this blog, you can support us by:
  1. Stay connected to: Facebook | Twitter | Google Plus | YouTube
  2. Subscribe email to recieve new posts from us: Sign up now.
  3. Start your own blog with SSD VPS - Free Let's Encrypt SSL ($2.5/month).
  4. Become a Supporter - Make a contribution via PayPal.
  5. Support us by purchasing Ribbon Lite Child theme being using on this website.

We are thankful for your support.

single post bottom banner
«« »»

Got something to say? Join the discussion

Please keep in mind that all comments are subject to our Comment Policy. Your email address will not be published.
This site uses Akismet to reduce spam. Learn how your comment data is processed.