POST data truncated in a cgi application

Discussion in 'Perl Misc' started by timnels@gmail.com, Aug 10, 2006.

  1. Guest

    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.
     
    , Aug 10, 2006
    #1
    1. Advertising

  2. Guest

    A. Sinan Unur wrote:
    > wrote in news:1155213393.018278.241120
    > @i42g2000cwa.googlegroups.com:
    >
    > > 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).

    >
    > I am not sure what you mean by the description above.
    >
    > > 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.

    >
    > 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.
    >
    > > 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 ?

    >
    > 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 <>
    > (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.
     
    , Aug 10, 2006
    #2
    1. Advertising

  3. wrote:

    > 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 (<$fh>);

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

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

    --
    Bart
     
    Bart Van der Donck, Aug 10, 2006
    #3
  4. Ted Zlatanov Guest

    On 10 Aug 2006, wrote:

    > 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
     
    Ted Zlatanov, Aug 10, 2006
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Guest

    truncated form post

    Guest, Jan 7, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    509
    Kevin Spencer
    Jan 7, 2004
  2. truncated form post

    , Jan 16, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    437
  3. Ian Lotinsky

    POST data truncated in Internet Explorer 6

    Ian Lotinsky, Apr 30, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    705
    Ian Lotinsky
    May 2, 2006
  4. dermoon
    Replies:
    0
    Views:
    514
    dermoon
    Oct 8, 2003
  5. Replies:
    7
    Views:
    301
    A. Sinan Unur
    Feb 14, 2006
Loading...

Share This Page