I am trying to use perl (ActivePerl 5.8.7 Build 813) to download a gzip file from a web server using LWP. Code:
use LWP::UserAgent; use LWP::Debug qw(level); level('+'); my $url = 'https://www.myurl.com/cgi-bin/file-download'; $ENV{HTTPS_PROXY} = 'PROXY'; $ENV{HTTPS_PROXY_USERNAME} = 'PROXY_USERNAME'; $ENV{HTTPS_PROXY_PASSWORD} = 'PROXY_PASSWORD'; my $ua = LWP::UserAgent->new; $ua->proxy(['http','https']); my $response = $ua->post( $url, Content_Type => 'form-data', Content => [ userid => 'USERID', password => 'PASSWORD', recordlength => '', recordterminator => 'NONE', remotefilename => 'REMOTE_FILENAME' ] ); if ($response->is_success) { print $response->content; } else { die $response->status_line; }

The POST to https://www.myurl.com/cgi-bin/file-download returns Content-Type: application/octet-stream and Content-Disposition: inline (basically a binary stream of inline data that is ultimately a GZIP file).

IE normally prompts you for a file name to save the file as and saves the file properly. However my $response->content has Carriage return/Line feeds throughout the binary stream returned. It does not always put a CrLf after 'x' numnber of characters; it seems to be randomly placed.

Now, I'm only about 95% convinced that the site isn't sending me the CrLf in the stream, but if I go to the site and click on the button that does the post from the "download" page it returns just fine.

The site's download page isn't too complex, so I'm quite sure I'm not missing a field I have to send in the post.

Any assistance of where to go from here would be appreciated.

In reply to CrLf getting inserted into an octet-stream (gzip file) by Rumtis

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.