Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending base64 data to an apache server (Apache/1.3.24 ) 1

Status
Not open for further replies.

GrahamBright

Programmer
Oct 31, 2003
65
AT
Hi all,

I have an interesting but frustrating problem.

I use a combination of LWP::UserAgent, HTTP:Header and HTTP::Request to submit a simple HTTP POST message to a Web Server containing a Base64 encoded picture.

I can submit the request to the Web Server with out difficultiy.

However, if I try to send a large Base64 encoded image (over 4k) in the request, the Base64 encoded data is corrupt.

I am not sure what is causing the corruption ? TCP segment length or line feeds.

Q. How can I remodel my application to submit BASE64 picture without line feeds.

Q. Why are the line feeds introduced, I think these are returned by Apache

With kind regards,

Graham.


Application code .

#!/opt/perl5/bin/perl

# $Revision: 1.1.1.3 $
#
# $Date: 2003/06/25 17:40:00 $
use LWP::UserAgent(keep_alive => 100,timeout =>60);
use HTTP::Request;
use HTTP::Headers;
use LWP::Debug qw(+);

my $objUserAgent = LWP::UserAgent->new;

#####additions
#$objUserAgent->max_size(2034);

$SOAP_FILE="/home/mkuetk/perlScripts/VASATPS/old/Soap_Request";

open(REQUEST, "<$SOAP_FILE") || die "Unable to open Soap Request file $!";

while ($Bytes = read(\*REQUEST, $Buffer, 500))

{
$soap_infile .= $Buffer;
chomp($soap_infile);
}



my $objHeader = HTTP::Headers->new;
$objHeader->authorization_basic("436641231239","msntest");
$objHeader->push_header('SoapAction' => '""');
$objHeader->push_header('Content-Length' => length($soap_infile));
$objHeader->push_header('Content-Type' => 'multipart/related; boundary="soap-border"; type="text/xml"; start ="<Test>"');
#Test System
my $objRequest = HTTP::Request->new("POST", ' $soap_infile);
my $objResponse = $objUserAgent->request($objRequest);


#Process Response#######
if ($objResponse->is_success)

{

print $objResponse->content;

}
close(REQUEST);

##############
 
Try to read the image at 'binmode' after you 'open' it.


TIMTOWTDI
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top