omsivan1 has asked for the wisdom of the Perl Monks concerning the following question:

When I use the following code I get a weird problem. Somehow the server that I poat to gets some junk values appended at the end of this value that send them. Hence they are not able to process it. If anyone can throw some light on this issue I will extremely grateful. Thanks in advance, Om The snippet is as follows:
if (open(fin,$filename)) { while (<fin>) { $body = "$body$_"; } close ($fin); my $blength = length($body); my $hblength = length($header) + $blength; my $header = "Version: 0.2 Username: $username Password: $password Organization: $organization Message Type: ANSI Usage: TEST Body Length: $blength Header Plus Body Length: $hblength "; $ua = LWP::UserAgent->new; $res = $ua->request(POST 'https://secure.inusasoft.com/stomp/servl +et/com.inusasoft.transport.adapters.inbound.http.HttpAdapter', Content_Type => 'multipart/form-data; boundary="ifyoucanse +ethisyourstuffisbroke"', Content => [ "$header$body" ]); open (fh, ">> $logfilepath/$now.txt"); print fh " $now $tnow----------------------------------------------------------- "; print fh $res->content; # Uncomment to display data sent to standard out print "$header$body"; # Uncomment to display data received to standard out print $res->content; close (fh); } else { open (fh, ">> $logfilepath/$now.txt"); print fh " $now $tnow---------------------------------------------------------- "; print fh "Cannot Open file: $filename"; print "Cannot Open $filename"; close fh }

janitored by ybiC: Balanced <code> tags around codeblock

Replies are listed 'Best First'.
Re: Help with https post
by iburrell (Chaplain) on Mar 23, 2004 at 01:09 UTC
    What is the request supposed to look like? Is it form data or some custom type? I don't see any field names. Let LWP construct the multipart/form-data body and read the file.
    my $req = POST($url, Content_Type => 'form-data', Content => [ name => 'value', file => [ $filename ] ]);
Re: Help with https post
by Vautrin (Hermit) on Mar 22, 2004 at 22:37 UTC
    If you want any help I would suggest editing your post so it contains the following:

    <p>Paragraphs should be inside p tags</p> <code>Code should be in code tags
    </code>

    Your post is very hard to read.


    Want to support the EFF and FSF by buying cool stuff? Click here.