I have small program that shows the equivalent problem when writing to a file:
use strict; use IO::File; my $fh = new IO::File("> qqq.txt"); defined($fh) || die "Cannot open qqq.txt\n"; #binmode($fh); my $CRLF = "\015\012"; print $fh "test",$CRLF; close $fh;
Without the binmode call, the file is written as "test\r\r\n". Unfortunately, the node A Little History on 0D0A says that binmode can only be used for files, not sockets. For sockets it recommends a $CRLF value like the one given above, but my test program shows that won't work. Windows sees it is supposed to print a "\012", cleverly expands that to "\015\012", and ends up doubling my carriage return.

In HTTP:Daemon, I find the following line (in the section for HTTP::Daemon::ClientConn):

my $CRLF = "\015\012"; # "\r\n" is not portable
Ironically, the given code isn't portable either! I patched it to have "012" instead.

Unfortunately, my content length still seems to be off this way, and I get the "unclosed token." Does anyone have a better work-around, or a way to set binary mode for sockets? Thanks.

Update: I have a work-around now on the client side, so I took out the patches on the server side. In Frontier::Client, I did the following:

my $content = $response->content; # Second-chance attempt for a broken Windows Frontier # service, which puts good results into client-junk. if (!$content) { my $headers = $response->headers; my $cjunk = $headers->{"client-junk"}; if (defined $cjunk) { # Reconstitute the result. $content = join("\n",@$cjunk); } }
This will work for the small amount of result contents that I need. There is clearly something wrong here that I have to make such a patch, but it will do for now.

In reply to Re: Frontier::Daemon over-returns lines by tall_man
in thread Frontier::Daemon over-returns lines by tall_man

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.