POST data truncated in a cgi application

T

timnels

I have what I thought was a simple CGI application which takes a POST
of a jpeg image from a Nextel phone (creates an HTTP request with
content type image/jpeg).

The CGI app seems (even though the phone sends more data) ALWAYS to
receive 8440 bytes. The code to receive this data is:

use CGI;
use CGI::Carp qw(fatalsToBrowser);

my ($data,@args);

$data = join '',<>;

# right here length($data) is always 8440.

I looked for an Apache setting that might be causing this, but I didn't
see anything. Can anyone point me in the right direction ? Thanks.
 
T

timnels

A. Sinan Unur said:
(e-mail address removed) wrote in @i42g2000cwa.googlegroups.com:


I am not sure what you mean by the description above.


Is it always 8440 bytes with the same image or is it 8440 with different
images?

You are using CGI.pm. Why are you not using CGI.pm and the documentation
of that module. I am assuming you are doing the equivalent of a file
upload form. There is a specific way in which the POST request to do
that needs to be formed. For more information on how to craft that
request and how to handle the incoming data, see the documentation for
CGI.pm.


There is also $CGI::pOST_MAX but I am not sure if it should have any
effect with the code above.

Sinan

--
A. Sinan Unur <[email protected]>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html

Ahh... sorry ... this problem (although it is ahrd to believe) seems to
the the app on the Java phone (or the J2ME implementation). An i860
phone works perfect for files over 8440, but has the error when I
install it on the i850.
 
B

Bart Van der Donck

I have what I thought was a simple CGI application which takes a POST
of a jpeg image from a Nextel phone (creates an HTTP request with
content type image/jpeg).

#!/usr/bin/perl
use strict;
use warnings;
use CGI qw/:standard/;
print "Content-Type: image/jpeg\n\n";
my $fh = upload('myfile');
print while ( said:
The CGI app seems (even though the phone sends more data) ALWAYS to
receive 8440 bytes. The code to receive this data is:

use CGI;
use CGI::Carp qw(fatalsToBrowser);
my ($data,@args);
$data = join '',<>;
# right here length($data) is always 8440.

You can't use <> and length() that way to retrieve file size. This
is a more 'official' way:

#!/usr/bin/perl
use strict;
use warnings;
use CGI qw/:standard/;
print "Content-Type: text/html\n\n";
my $fh = upload('myfile');
print 'Size = ' . (stat ($fh))[7] . ' bytes';

I'm using the following form:

<html>
<body>
<form method="post"
action="script.cgi"
enctype="multipart/form-data">
<input type="file" name="myfile">
<input type="submi"t>
</form>
</body>
I looked for an Apache setting that might be causing this, but I didn't
see anything.

I don't see how Apache could be involved in this.
Can anyone point me in the right direction ?

http://search.cpan.org/dist/CGI.pm/CGI.pm

Hope this helps,
 
T

Ted Zlatanov

Ahh... sorry ... this problem (although it is ahrd to believe) seems to
the the app on the Java phone (or the J2ME implementation). An i860
phone works perfect for files over 8440, but has the error when I
install it on the i850.

You may find it useful to learn about tcpdump, Ethereal, or any other
tools for your OS to look at the actual data going across the wire.
Often this is useful to ensure that the data you expect is actually
coming to you (as you saw here, that doesn't always happen).

Ted
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,150
Latest member
MakersCBDReviews
Top