I put in a lot of time to come up with a solution on a previous occasion.

Update: Here is a module that adds a post function to Win32::IE::Mechanize.

=pod Win32/IE/Mechanize/Post.pm Adds function post to Win32::IE::Mechanize if it doesn't already exist. usage: use Win32::IE::Mechanize::Post; -or- use Win32::IE::Mechanize::Post (); The post function accepts for arguments anything HTTP::Request::Common::POST would accept. $ie->post('http://www.example.com/survey.cgi', [ name => 'John Doe', email => 'doe@example.org', gender => 'M', born => '1976', perc => '3%', ]); # multipart/form-data $ie->post('http://www.example.com/survey.cgi', Content_Type => 'form-data', Content => [ name => 'John Doe', email => 'doe@example.org', gender => 'M', born => '1976', init => ["$ENV{HOME}/.profile"], ], ); =cut use strict; use warnings; use Win32::IE::Mechanize qw( ); package Win32::IE::Mechanize; use HTTP::Request::Common qw( ); use Win32::OLE::Variant ;# qw( Variant VT_* ); if (!*post{CODE}) { *post = sub { my $self = shift; my $agent = $self->{agent}; local $HTTP::Request::Common::DYNAMIC_FILE_UPLOAD = 0; my $request = HTTP::Request::Common::POST( @_ ); my $uri = $request->uri; ($uri = $self->uri ? URI->new_abs( $uri, $self->uri->as_string ) : URI->new( $uri ) ); my $headers = $self->_extra_headers( $uri ) . $request->headers_as_string( "\015\012" ); $agent->navigate({ URL => $uri->as_string, Headers => $headers, PostData => Variant( VT_UI1, $request->content ), }); $self->_wait_while_busy; }; } 1;

Untested. Let me know if there are any problems.

Next step: testing it and submitting it as a patch.


In reply to Re: create a POST request from scratch using Win32::IE::Mechanize by ikegami
in thread create a POST request from scratch using Win32::IE::Mechanize by holli

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.