The situation goes like this: So this is the code I have so far. But it doesn't seem to work. When I direct the output to a file, instead of the webserver, it appears to all be there. Just now, I tried to test it with open(OUT, "|telnet www 10941") instead of the other open(OUT...) (port 10941 is a fake webserver that just dumps any input to a file.), and it appears to be disconnecting before it finishes sending $mime. I'm at about my limit of being able to test/figure out what's wrong. Maybe I just can't make heads or tails out of the right MIME RFC's (which all assume you are trying to do email, and that you already know the HTTP headers you should be using instead (which I don't and can't seem to find documentation for)). Any help within my (above) context gratefully accepted.
#!/usr/bin/perl use MIME::Base64 (); # put some error checking here eventually $user = $ARGV[0]; $pass = $ARGV[1]; $file = $ARGV[2]; open(OUT,"|/usr/local/openssl/bin/openssl s_client -v -connect www:443 +") or die "Failure\n"; binmode OUT; $bound = "---------------------------2218759766176618872063491442"; # print out header stuff print OUT "POST /cgi-bin/save HTTP/1.0\n"; print OUT "Referer: https://www/upload.html\n"; print OUT "Connection: Keep-Alive\n"; print OUT "User-Agent: Amelindinator/0.1 [en] (amelinda\@mydomain.com) +\n"; print OUT "Host: www.mydomain.com:443\n"; print OUT "Content-type: multipart/form-data; boundary=$bound\n"; print OUT "Content-Length: "; # calculate content length open(FILE, "$file") or die "$!"; binmode FILE; # I'm not sure I need this. local($/) = undef; # slurp $mime = MIME::Base64::encode(<FILE>); close(FILE); $len = (length $mime) + (length $user) + (length $pass); $len += 514; # this is stuff that is constant # print rest of stuff. print OUT "$len\n\n"; print OUT "--$bound\n"; print OUT "Content-Disposition: form-data; name=\"user\"\n\n"; print OUT "$user\n"; print OUT "--$bound\n"; print OUT "Content-Disposition: form-data; name=\"pass\"\n\n"; print OUT "$pass\n"; print OUT "--$bound\n"; print OUT "Content-Disposition: form-data; name=\"FILE\"; filename=\"$ +file\"\n"; print OUT "Content-Transfer-Encoding: BASE64\n\n"; print OUT $mime; # print out the mimencoded bit here print OUT "--$bound\n"; print OUT "Content-Disposition: form-data; name=\"SUBMIT\"\n\n"; print OUT "Submit\n"; print OUT "--$bound--\n"; # close the stream, silly! close(OUT); exit;

In reply to amelinda's HTTP/MIME/file upload/not-a-cgi-but-a-client/minimal-module/perl problem by amelinda

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.