Hello wise ones,
I'm exercising me on LWP and HTTP::* modules writing a tool aiming to timing the response of the webserver in detail.

The tool is htmlpage orientented; meaning that I will consider and discern the different elements constituing the html page resulting from the request. IE I will time separately the reception of the body and the content included in it.

I was in first approch relaing on the content_lenght header but I found it was not received from every webserver so (now the questions):

1) can I safely assume that $size_body = length ($response->content) ?

Now start the confusion: length says: "Returns the length in characters of the value of EXPR." while the camel book states: "Returns the length in bytes of the scalar value val.".
Following this little difference I discovered the bytes pragma (in this page I learned that  chr(400) is one character but two bytes) and new question born:

2)Considering now I'm working with unpredictable html output I have to do this esoteric operation counting the bytes I receive back  $size_body = bytes::length ($response->content)? and:

3)I have to consider also the content type and the encoding (returned in headers) to calculate the more accurate size in bytes (as definetively data come to me in bytes over the network..) of the response content?

4)to be accurate I have to time and size the response code and the message received back before headers, then headers, then the body and also (the response code and message too?) of any embedded element in the page?

thanks for the attention and for eventual answers

Lor*


there are no rules, there are no thumbs..

In reply to Size and anatomy of an HTTP response by Discipulus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.