Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to determine the size of a http response header?

I want to determine the size of the response header. I assume I could do so by subtracting the size of the response body from the combined size derived using Chrome DevTools.

From Chrome DevTools:

Size is the combined size of the response headers (usually a few hundred bytes) plus the response body, as delivered by the server.

The uncompressed size of a .js file is 375 bytes, given by the Content. The combined size given by DevTools is 701 bytes.

In addition, I have the following information from Apache access log to record the transfer of the same .js file:

%b = 273 bytes (Size of response in bytes, excluding HTTP headers)
%O = 842 bytes (Bytes sent, including headers, cannot be zero)

Should I use %0 - %b, %0 - Content, Size - %b or Size - Content? In addition, can anyone tell me why there is a difference between %0 and Size?

like image 840
Question Overflow Avatar asked Dec 03 '13 04:12

Question Overflow


People also ask

What is the size of HTTP header?

The default HTTP Request Header value is 8190 bytes.

What is HTTP response size?

The response limit is 9,223,372,036,854,775,807 bytes (2 ** 64).

What is content Length in response header?

The Content-Length header indicates the size of the message body, in bytes, sent to the recipient.

Does HTTP headers have a fixed size?

No, HTTP does not define any limit. However most web servers do limit size of headers they accept. For example in Apache default limit is 8KB, in IIS it's 16K. Server will return 413 Entity Too Large error if headers size exceeds that limit.


1 Answers

I dont know what tool you need, but its easy to count in shell using curl utility, assuming you have following header:

root@sup ~# curl -I  http://domain.com
HTTP/1.1 200 OK
Server: nginx/1.2.1
Date: Thu, 05 Dec 2013 19:40:40 GMT
Content-Type: text/html
Content-Length: 199
Last-Modified: Sun, 15 Sep 2013 17:06:37 GMT
Connection: keep-alive
Accept-Ranges: bytes

to count it:

root@sup ~# curl -s -w \%{size_header} -o /dev/null http://domain.com 
215

result: 215 bytes.

like image 138
swserg Avatar answered Sep 19 '22 05:09

swserg