I've made some progress since my stupid and, admitedly, rather careless,
error with the upload_hook extended by libapreq.  I finally gave up on
debugging it in it's current context and made a seperate light module setup
just to test.  Currently, I'm using the Apache::Test::UploadMeter namespace
(if this all works, I suppose I'll copy this project to CPAN under the
Apache::UploadMeter namespace).  In any case, here's what I've got so far:

Apache/Test/UploadMeter.pm
---
package Apache::Test::UploadMeter;

use strict;
use warnings qw(all);
use diagnostics;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
use Apache;
use Apache::Constants qw(OK DECLINED HTTP_MOVED_TEMPORARILY BAD_REQUEST
NOT_FOUND);
use Cache::FileCache;  # For Win32 compatibility - required for IPC from
upload_hook to upload_meter

BEGIN {
    use Exporter ();
    $VERSION=0.01;
    @ISA=qw(Exporter);
    @EXPORT=();
    @EXPORT_OK=qw ( );
    %EXPORT_TAGS=();
}

### Version History
# 0.01 : Oct  14, 2001 - Started

### Globals
my
%cache_options=('default_expires_in'=>900,'auto_purge_interval'=>60,'namespa
ce'=>'u_hook'); #If the hooks don't get called in 15 minute, assume it's
done

sub handler
{
    my $r=shift;
    ### Upload hook handler
    my $hook_handler=sub {
        my ($upload, $buf, $len, $hook_data)=@_;
        Apache->log_error("$hook_data: got $len bytes for ".$upload->name);
    };
    my $q=Apache::Request->instance($r,
HOOK_DATA=>"hardcoded",UPLOAD_HOOK=>$hook_handler,
TEMP_DIR=>"/home/www/spool");
    my $file=$q->upload;
    my $fname=$file->filename;
    $r->send_http_header('text/plain');
    $r->print("done\n\n$fname");
    return OK;
}

1;

__END__
============

httpd.conf
---
<Location /test>
  SetHandler perl-script
  PerlHandler Apache::Test::UploadMeter
</Location>

============

When doing an upload from a blank HTML page (just a form with an upload
field), I get the following output in the browser:
done

D:\EXPORTS\Log.txt

...and the following output in error_log:

[Sun Oct 14 16:49:12 2001] [error] [client 192.168.1.1] request failed:
error reading the headers

Something's obviously not working right.  The only clue I have is that the
error is _definately_ caused by the upload hook, because when I remove that
from the code, I get no errors in error_log.  Any help on this would be
appreciated...

  Issac


Internet is a wonderful mechanism for making a fool of
yourself in front of a very large audience.
  --Anonymous

Moving the mouse won't get you into trouble...  Clicking it might.
  --Anonymous

PGP Key 0xE0FA561B - Fingerprint:
7E18 C018 D623 A57B 7F37 D902 8C84 7675 E0FA 561B

Reply via email to