Hello Monks,

I am trying to POST to a Java servlet that is expecting multipart/form-data that conforms to W3C RFC-1341 section 7.2 . I am using LWP::UserAgent to generate the request, but it is not generating the boundary value in the HTTP headers. I have not seen any mention of a boundary value in any of the LWP related modules. According to the spec there should be a boundary=boundary_value after the Content-Type in the HTTP headers. Something like this;

Content-Type: multipart/form-data; boundary=_OPERAB__xxx

Do any of you wise people know how I can get the boundary in there. Do any of you have the Fonz like powers to tap my code and make the elusive boundary appear?

Here is the code:
my $ua = LWP::UserAgent->new; my $req = HTTP::Request->new; $req->method('POST'); $req->uri($servlet); $req->content_type('multipart/form-data'); $req->content("xmlmsg=$xmlmsg"); $req->authorization_basic($uid, $pass); # make the request to server my $res = $ua->request($req); print "\nREQUEST\n" . $req->as_string; print "\nRESPONSE\n" . $res->as_string;
The results are printed below:
REQUEST POST http://myservername.com/LLS/GenPublishMessage Authorization: Basic Z2thaG46bWF4aW5lMTMxMw== User-Agent: libwww-perl/5.64 Content-Type: multipart/form-data xmlmsg=<?xml version="1.0" encoding="UTF-8" ?><message id="EA10" prior +ity="High" timezone="CET" user_type="I"><head><active><from>9-Jul-02 +11:20:00 </from><to>9-Jul-02 11:20:00 </to></active><author id="gkahn +"/><attribute type="CATEGORY" value="GEEVENT"/><attribute type="COUNT +RY" value="EUROAREA"/><entitlement_attribute type="PERIOD" value="Jul +"/><entitlement_attribute type="PREV2" value="3.32"/><entitlement_att +ribute type="PREV1" value="3.33"/><entitlement_attribute type="LATEST +" value="3.36"/><entitlement_attribute type="LBGE" value="3.33"/><ent +itlement_attribute type="MARKET" value="na"/></head><body><title>ECB +refinancing operation (average rate) </title><content>ECB </content>< +/body></message> RESPONSE HTTP/1.1 200 OK Connection: close Date: Wed, 31 Jul 2002 19:44:18 GMT Server: Netscape-Enterprise/4.1 Content-Type: text/xml Client-Date: Wed, 31 Jul 2002 19:44:18 GMT Client-Response-Num: 1 <?xml version="1.0"?> <LL_BULLETIN_BOARD_PUBLISHING STATUS="FAILED"> java.io.IOException: Separation boundary was not specified </LL_BULLETIN_BOARD_PUBLISHING>
Get Strong Together!!

In reply to Separation boundary in multipart/form-data POSTs by aardvark

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.