POST data truncated in a cgi application

POST data truncated in a cgi application

Post by timnel » Fri, 11 Aug 2006 21:36:33


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.
 
 
 

POST data truncated in a cgi application

Post by A. Sinan U » Fri, 11 Aug 2006 22:43:03


@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 < XXXX@XXXXX.COM >
(remove .invalid and reverse each component for email address)

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

 
 
 

POST data truncated in a cgi application

Post by timnel » Fri, 11 Aug 2006 23:15:28


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.
 
 
 

POST data truncated in a cgi application

Post by Bart Van d » Fri, 11 Aug 2006 23:20:45


#!/usr/bin/perl
use strict;
use warnings;
use CGI qw/:standard/;
print "Content-Type: image/jpeg\n\n";
my $fh = upload('myfile');
print while (<$fh>);


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>
</html>


I don't see how Apache could be involved in this.


http://www.yqcomputer.com/

Hope this helps,

--
Bart
 
 
 

POST data truncated in a cgi application

Post by Ted Zlatan » Sat, 12 Aug 2006 02:41:19


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