You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Malcolm <mj...@liminalflux.net> on 2008/01/10 00:07:07 UTC

Apache2::Upload partial upload

Is there any way to get some of the pieces of an incomplete multi-part post?

The situation I have is a client uploading multiple files as pieces of a POST, 
but then timing out in some manner whilst doing so. I know I'm getting some 
of the files (I have an upload_hook in place that dumps the file names as 
they come in), but if I do 

	my $req = Apache2::Request->new($r);
	$upload = $req->upload($upload_filename);

all I get is an "End of file found" error (APR::Request::Error with a rc of 
70014), even on files that have uploaded completely by that point.

Apache2::Request::upload calls $req->body (which is incomplete, and presumably 
part of the problem).

Versions:
	libapreq2-2.07
	mod_perl-2.0.1
	httpd-2.0.59

It looks like libapreq 2.08 might give me a little better error reporting 
(that's next on my list to see if I can work out what's happening with the 
connection) but doesn't solve the partial upload problem.

Anyone have any ideas?


Re: Apache2::Upload partial upload

Posted by Malcolm <mj...@liminalflux.net>.
On Wednesday 09 January 2008 9:54:57 pm Foo JH wrote:

> Is there any value in receiving an incomplete upload? 

Yes. The upload consists of multiple files in a multi-part POST. Getting some 
of the files is better than getting none of the files.

> Are you better off deciding how to avoid the timeout instead?

The problem there is that I'm dealing with a custom client (I'm not actually 
serving a website, the client end is a automated program not a browser), and 
if we ship a new client, it takes about a year for 100% of the machines to be 
updated. So if the timeout is client related (which is probable), and 
fixable, it's still going to be a year before we've solved the problem. So 
partial solutions for the interim are desireable.


Re: Apache2::Upload partial upload

Posted by Foo JH <jh...@extracktor.com>.
Is there any value in receiving an incomplete upload? Are you better off 
deciding how to avoid the timeout instead?

Malcolm wrote:
> Is there any way to get some of the pieces of an incomplete multi-part post?
>
> The situation I have is a client uploading multiple files as pieces of a POST, 
> but then timing out in some manner whilst doing so. I know I'm getting some 
> of the files (I have an upload_hook in place that dumps the file names as 
> they come in), but if I do 
>
> 	my $req = Apache2::Request->new($r);
> 	$upload = $req->upload($upload_filename);
>
> all I get is an "End of file found" error (APR::Request::Error with a rc of 
> 70014), even on files that have uploaded completely by that point.
>
> Apache2::Request::upload calls $req->body (which is incomplete, and presumably 
> part of the problem).
>
> Versions:
> 	libapreq2-2.07
> 	mod_perl-2.0.1
> 	httpd-2.0.59
>
> It looks like libapreq 2.08 might give me a little better error reporting 
> (that's next on my list to see if I can work out what's happening with the 
> connection) but doesn't solve the partial upload problem.
>
> Anyone have any ideas?
>
>   


Re: Apache2::Upload partial upload

Posted by Mark Alway <mo...@markalway.com>.
On Jan 10, 2008, at 6:50 AM, Malcolm wrote:

> On Wednesday 09 January 2008 10:28:39 pm Mark Alway wrote:
>
>> (did I get this sent to the list or just back to Malcolm...I don't  
>> see
>> the list address in the subscribe confirmation?)
>
> Just to me. cc'd back to the list
>
>> I'm having a very similar problem.  My setup:  Apache/2.2.6 (Unix)
>> mod_ssl/2.2.6 t/mixed mod_apreq2-20051231/2.6.0 mod_perl/2.0.3 Perl/
>> v5.8.6
>>
>> I'm using a very simple Upload script for testing and every 4th or  
>> 5th
>> upload from a Safari browser the server just hangs.  After the 60
>> seconds specified as the timeout in my Apache config the error_log
>> reports:
>>
>> [Wed Jan 09 18:49:09 2008] [error] [client 192.168.1.6] (70007)The
>> timeout specified has expired: ap_get_brigade failed during prefetch,
>> referer: http://192.168.1.2/test_upload.html
>> [Wed Jan 09 18:49:09 2008] [error] Internal apreq error
>
> What's your Timeout set to in the apache config?

60 seconds.  It doesn't take 60 seconds upload a 43 byte file on a  
local network.
>
>
>> If I was to click on a different link or stop the browser while
>> waiting for the server I get this in the error log:
>>
>> [error] End of file found
>
> If you stop the browser whilst it's uploading, then I'd expect that
> behaviour - you've interupted the POST.
>
Well yes, but only because it hangs....the file is uploaded by the  
browser is hung and if I don't click something it will timeout and  
error.
>
>> When I used the $io->read() function versus <$io> the message reads:
>>
>> [error] Apache2::RequestIO::read: (70014) End of file found at (eval
>> 23) line 5
>>
>> I can reproduce this but only with Safari browsers.  Firefox seems
>> immune.  I ran a TCP dump of the process with a 43 byte uploaded file
>> and couldn't see any noticeable differences between the way the
>> browsers posted.  Using <$io> seems to be better than $io->read() but
>> both still exhibit the problem.
>
> Can you reproduce it with the 43 byte file, or was that just for  
> comparing the
> dumps? I'm only running into this after around a few hundred Kb, and  
> then
> it's dependent on line quality (thus doesn't happen during on-site  
> testing).
>
>
It happens with the 43 byte file too.  I used something small for  
testing to make sure it wasn't just related to file size limits.
>>
>> Below is my HTML form file and Mod_Perl script.  Both incredibly
>> simple, but causing a major headache:
>>
>> --------- HTML -----------
>> <form method="post" action="test_upload.cgi" enctype="multipart/form-
>> data" name="student_info"> <input type="text" name="good" /> <input
>> type="file" name="upload_photo" /> <input type="submit"> </form>
>> ------------- ModPerl Code --------------
>> use strict;
>> use warnings;
>> use Apache2::RequestUtil;
>> use Apache2::Request;
>> use Apache2::Upload;
>>
>> my $r = Apache2::RequestUtil->request();
>>
>> my $req = Apache2::Request->new($r);
>>
>> # Get the photo that was uploaded
>>
>> my $upload = $req->upload('upload_photo');
>>
>> my $size = $upload->size();
>>
>> open(WRITE, ">/usr/local/apache2/html/0001.jpg") or die("Can't open
>> 0001.jpg for write  $!");
>>
>> my $io = $upload->io;
>> print WRITE while <$io>;
>>
>> close(WRITE);
>>
>> print "Content-type: text/html\n\n";
>>
>> print "Success";
>>
>> exit;
>

Mark Alway
mark@markalway.com




Re: Apache2::Upload partial upload

Posted by Malcolm <mj...@liminalflux.net>.
On Wednesday 09 January 2008 10:28:39 pm Mark Alway wrote:

> (did I get this sent to the list or just back to Malcolm...I don't see
> the list address in the subscribe confirmation?)

Just to me. cc'd back to the list

> I'm having a very similar problem.  My setup:  Apache/2.2.6 (Unix)
> mod_ssl/2.2.6 t/mixed mod_apreq2-20051231/2.6.0 mod_perl/2.0.3 Perl/
> v5.8.6
>
> I'm using a very simple Upload script for testing and every 4th or 5th
> upload from a Safari browser the server just hangs.  After the 60
> seconds specified as the timeout in my Apache config the error_log
> reports:
>
> [Wed Jan 09 18:49:09 2008] [error] [client 192.168.1.6] (70007)The
> timeout specified has expired: ap_get_brigade failed during prefetch,
> referer: http://192.168.1.2/test_upload.html
> [Wed Jan 09 18:49:09 2008] [error] Internal apreq error

What's your Timeout set to in the apache config?

> If I was to click on a different link or stop the browser while
> waiting for the server I get this in the error log:
>
> [error] End of file found

If you stop the browser whilst it's uploading, then I'd expect that 
behaviour - you've interupted the POST.


> When I used the $io->read() function versus <$io> the message reads:
>
> [error] Apache2::RequestIO::read: (70014) End of file found at (eval
> 23) line 5
>
> I can reproduce this but only with Safari browsers.  Firefox seems
> immune.  I ran a TCP dump of the process with a 43 byte uploaded file
> and couldn't see any noticeable differences between the way the
> browsers posted.  Using <$io> seems to be better than $io->read() but
> both still exhibit the problem.

Can you reproduce it with the 43 byte file, or was that just for comparing the 
dumps? I'm only running into this after around a few hundred Kb, and then 
it's dependent on line quality (thus doesn't happen during on-site testing).


>
> Below is my HTML form file and Mod_Perl script.  Both incredibly
> simple, but causing a major headache:
>
> --------- HTML -----------
> <form method="post" action="test_upload.cgi" enctype="multipart/form-
> data" name="student_info"> <input type="text" name="good" /> <input
> type="file" name="upload_photo" /> <input type="submit"> </form>
> ------------- ModPerl Code --------------
> use strict;
> use warnings;
> use Apache2::RequestUtil;
> use Apache2::Request;
> use Apache2::Upload;
>
> my $r = Apache2::RequestUtil->request();
>
> my $req = Apache2::Request->new($r);
>
> # Get the photo that was uploaded
>
> my $upload = $req->upload('upload_photo');
>
> my $size = $upload->size();
>
> open(WRITE, ">/usr/local/apache2/html/0001.jpg") or die("Can't open
> 0001.jpg for write  $!");
>
> my $io = $upload->io;
> print WRITE while <$io>;
>
> close(WRITE);
>
> print "Content-type: text/html\n\n";
>
> print "Success";
>
> exit;