Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Doing what I said seems to work to me

#!/usr/bin/perl -- use strict; use warnings; use WWW::Mechanize 1.73; my $ua = WWW::Mechanize->new; $ua->timeout(0.1); $ua->add_handler("request_send", sub { shift->dump; return }); $ua->add_handler("response_done", sub { shift->dump; return }); $ua->show_progress(1); $ua->put_multi( 'http://localhost', Content_Type => 'multipart/form-data', Content => [ fileuploadfieldname => [ undef, # filename_to_read or none in this case "filenamesent", -content => 'i sent you some content named filenamesent' ], ], ); sub WWW::Mechanize::put_multi { my( $self, $uri, @parameters ) = @_; $uri = $uri->url if ref($uri) eq 'WWW::Mechanize::Link'; $uri = $self->base ? URI->new_abs( $uri, $self->base ) : URI->new( $uri ); unshift @parameters, $uri->as_string; require HTTP::Request::Common; my @suff = $self->_process_colonic_headers(\@parameters,1); my $req = HTTP::Request::Common::POST( @parameters, ); $req->method('PUT'); return $self->request( $req, @suff ); } __END__ $ perl ** PUT http://localhost ==> PUT http://localhost Accept-Encoding: gzip User-Agent: WWW-Mechanize/1.73 Content-Length: 163 Content-Type: multipart/form-data; boundary=xYzZY --xYzZY\r Content-Disposition: form-data; name="fileuploadfieldname"; filename=" +filenamesent"\r -Content: i sent you some content named filenamesent\r \r \r --xYzZY--\r\n 500 Can't connect to localhost:80 Content-Type: text/plain Client-Date: Thu, 02 Apr 2015 08:49:31 GMT Client-Warning: Internal response Can't connect to localhost:80\n No connection could be made because the target machine actively refuse +d it. at .../site/lib/LWP/Protocol/ line 49.\n 500 Can't connect to localhost:80 (1s) Error PUTing http://localhost: Can't connect to localhost:80 at lwp-me line 62.

In reply to Re: PUT a Multipart request in PERL ( ) by Anonymous Monk
in thread PUT a Multipart request in PERL by xpert

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others avoiding work at the Monastery: (3)
    As of 2020-12-02 07:10 GMT
    Find Nodes?
      Voting Booth?
      How often do you use taint mode?

      Results (35 votes). Check out past polls.