views:

44

answers:

2

I want to calculate the size in bytes of the http response headers and data in PHP. Any help would be appreciated

+1  A: 

You can't measure the size of the response headers from your PHP code because the webserver may change them before serving them up. Only the webserver can measure this - and you don't say what webserver you are using. With Apache, install mod_logio and start recording %I, %O and %B

symcbean
getheaders() would give you the complete header response, but it would add to additional call
RJ
@RJ: only after the headers have been flushed (and only if the encoding is not chunked)
symcbean
@symcbean Could you explain "encoding is not chunked", i didn't get it
RJ
@RJ: if the encoding is chunked, then the webserver will send a set of headers, then the first chunk of the body, then more content which is effectively a header before the next chaunk - your PHP code doesn't know where the webserver has split the body
symcbean
A: 

I think this will do my work.....any clues?

RJ