Most esteemed Monks,

I've searched for a while on this one. I would like to retrieve data sent via the HTTP Content area. Normally, to upload a file to a CGI one would specify the form-data to contain a form variable of type file and then the file, LWP example of this:
my $ua = new LWP::UserAgent; my $res = $ua->request(POST 'http://myserver.com/Parse.pl', Content_Type => 'form-data', Content => [file => ['Test.ini']]);
CGI.pm example of reading the file:
my $query = CGI->new(); my $file = $query->param('file'); my $mimetype = $query->uploadInfo($file)->{'Content-Type'}; my $data; binmode $file if $mimetype !~ /text/; while (read ($file, $data, 1024)) { # do something with data }
CGI.pm can easily pull the file variable and file. The program uploading to my CGI is doing the equivalent of this (but in Java):
my $ua = new LWP::UserAgent; my $res = $ua->request(POST 'http://myserver.com/Parse.pl', Content => $file);
The file is stored after the Content-type: 'application/x-www-form-urlencoded' (in this case HTTP::Request is generating that for me, I could specify it). Anyway, I have not found any documentation explaining how to do this. I would like to use CGI.pm, but it seems like it parses the file (in Content-type) as if it were form-data. LWP doesn't seem to work here either. I assume this has been solved before, I just have not found the solution. Any help you can give will be greatly appreciated.

Thank you!

Casey

In reply to File Sent via HTTP Content by cmilfo

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.