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
                   2010-10-27 11:19:13
                
              getheaders() would give you the complete header response, but it would add to additional call
                  RJ
                   2010-10-27 11:51:20
                @RJ: only after the headers have been flushed (and only if the encoding is not chunked)
                  symcbean
                   2010-10-27 15:51:01
                @symcbean Could you explain "encoding is not chunked", i didn't get it
                  RJ
                   2010-10-28 05:43:44
                @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
                   2010-10-28 16:34:09