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!!