If you just want the codes (as you say) just read the header....If you want an HTTP::Response Object just create one by splitting the return into header and content. Parse the header ( All in form Key: Value\n - should unwrap soft line breaks first with s/\n^\s+//gm first ) then build your HTTP::Response object out of the parsed header and content. Note HTTP::Response is a subclass of HTTP::Message which also uses HTTP::Headers so you will have to read the (brief) docs for all of these. Data::Dumper will show you the Response object which is just a hash of hashes structure.

C:\>type test.pl use IO::Socket::INET; $get = 'www.perl.org'; $sock = IO::Socket::INET->new(PeerAddr => $get, PeerPort => 'http(80)', Proto => 'tcp'); print $sock "GET http://$get HTTP/1.0\015\012\015\012"; read( $sock, $chopped_header , 100); close $sock; my ( $rc, $msg ) = $chopped_header =~ m/HTTP[^\s]+\s+(\d+)\s+([^\n]+)/ +; print "$chopped_header.....[blah]\n\n"; print "RC=$rc and MSG=$msg\n"; C:\>perl test.pl HTTP/1.0 200 OK Date: Sun, 30 Mar 2003 11:59:58 GMT Server: Apache/2.0.44-dev (Unix) DAV/2 Accept.....[blah] RC=200 and MSG=OK C:\>

cheers

tachyon

s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print


In reply to Re: create a HTTP::Response object from a raw buffer? by tachyon
in thread create a HTTP::Response object from a raw buffer? by edan

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.