You should be sending/getting a data stream like:

200 OK\015\012 Some-Header: value\015\012 Other-Header: value\015\012 \015\012 Body\015\012 Body\015\012 Body\015\012

Presuming you send it by POST (as opposed to GET) it will arrive on STDIN for your script. You can then do:

# set input operator to CRLF $/ = "\015\012"; # read header line by line while ( my $head = <STDIN> ) { last if m/^\015\012/; # must be a header line # do stuff } # header finished so read body line-wise while ( my $body = <STDIN> ) { # do whatever }

I can't think of many good reasons to be doing all this by hand. There are plenty of ways to move data without getting back to basics as it were. Perhaps if you mention what your are trying to achieve we may be able to suggest the easy way to you.... You may well find that the library modules HTTP::Request HTTP::Message and LWP::UserAgent do everyting you need (and probably more).

Note that you have to wrap long lines if you want to conform to the RFCs with soft line breaks when you send data. You therefore have to unwrap it at the other end.

some very very very very very very very very very long single line that just keeps on and on and on going and going and going finally we get to a real new line.....

cheers

tachyon

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


In reply to Re: Skirting the edges of RFC2616 in perl... by tachyon
in thread Skirting the edges of RFC2616 in perl... by tid

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.