Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Separation boundary in multipart/form-data POSTs

by Shendal (Hermit)
on Jul 31, 2002 at 20:30 UTC ( #186597=note: print w/ replies, xml ) Need Help??


in reply to Separation boundary in multipart/form-data POSTs

See perldoc HTTP::Request::Common (it's online here). It specifically addresses multi-part form-data under the POST heading.

Cheers,
Shendal


Comment on Re: Separation boundary in multipart/form-data POSTs
Download Code
Re: Re: Separation boundary in multipart/form-data POSTs
by aardvark (Pilgrim) on Jul 31, 2002 at 21:33 UTC
    Thanks for the reply Shendal, but HTTP::Request::Common lacks some features that I need for this to work. Namely Authentication. It surprises me that HTTP::Request::Common would construct the headers in a diferent way than HTTP::Request.

    I tried it with HTTP::Request::Common and got the following results:
    Code: my $ua = LWP::UserAgent->new; my $res = $ua->request(POST 'http://myserver.com/LLS/GenPublishMessa +ge', Content_Type => 'multipart/form-data', [xmlmsg => $xmlmsg]); Response: HTTP/1.1 302 (Found) redirecting for authentication purposes Connection: close Date: Wed, 31 Jul 2002 21:23:53 GMT Location: http://myserver.com/securecontrol/ct_logon_int_qa.html?ct_or +ig_uri=%2FLLS%2FGenPublishMessage Server: Netscape-Enterprise/4.1 Client-Date: Wed, 31 Jul 2002 21:23:53 GMT Client-Response-Num: 1 P3P: CP="NON CURa ADMa DEVa TAIa IVAa OUR DELa SAMa LEG UNI PRE"
    Get Strong Together!!
      I think what you want is to pass to your content method an array reference, not a string. In your first example,  $req->content("xmlmsg=$xmlmsg"); should be $req->content([ xmlmsg => $xmlmsg ]);.

      The pertinent part of the man page I was referring to is:
      The POST method also supports the multipart/form-data content used for Form-based File Upload as specified in RFC 1867. You trigger this content format by specifying a content type of 'form-data' as one of the request headers. If one of the values in the $form_ref is an array reference, then it is treated as a file part specification with the following interpretation:
      [ $file, $filename, Header => Value... ]
      The first value in the array ($file) is the name of a file to open. This file will be read and its content placed in the request. The routine will croak if the file can't be opened. Use an undef as $file value if you want to specify the content directly. The $filename is the filename to report in the request. If this value is undefined, then the basename of the $file will be used. You can specify an empty string as $filename if you don't want any filename in the request.

      Note that I have not tested this code, but I hope it points you in the right direction.
      Cheers,
      Shendal

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://186597]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (7)
As of 2014-12-27 12:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (177 votes), past polls