Re: Apache::Request UPLOAD_HOOK

2001-10-10 Thread Issac Goldstand

OK.  I get all that.  Now I'm getting a very strange error when I try to use
the hook.  the error from the error_log is: Undefined subroutine
Apache::Upload::handler called at /dev/null line 1.

Here is the code that calls the hook:

sub header_parser_handler($)
{
my $=shift;
my $hook_handler= sub {
my ($upload, $buf, $len, $hook_data)=@_;
$hook_cache-set($hook_data,$len);
Apache-log_error($hook_data: got $len bytes for .$upload-name);
};

my %cookies=Apache::Cookie-fetch;
my $u_id=$cookies{u_id}-value;
my
$q=Apache::Request-instance($r,TEMP_DIR=/home/www/spool,HOOK_DATA=$u_i
d,UPLOAD_HOOK=$hook_handler);
 return OK;
}

Any idea what's going on here?

  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




- Original Message -
From: Joe Schaefer [EMAIL PROTECTED]
To: Issac Goldstand [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Monday, October 08, 2001 19:16
Subject: Re: Apache::Request UPLOAD_HOOK


 Issac Goldstand [EMAIL PROTECTED] writes:

  The documentation on how to use this feature is a bit sketchy...

 Yes, I agree. Doc patches are always welcome.

 Comments below are from memory since I last tested this feature
 about 6 months ago.

  Can anyone explain: 1) What the variables passed to the callback
  function are (looks like the Apache::Upload object is the first, but
  what's been filled in there when the hook gets called?

 The current upload object goes there when the hook is called.

  The second looks like the current bunch of data that's been
  recieved[?],

 Right, it's the buffer from apache's ap_get_client_block,
 which is usually around 2-4 KB.  The hook runs before the
 buffer gets written to the underlying tempfile, but as soon
 as your hook has completed, Apache::Request will write it
 automatically.

  the third is the length, but is that the length recieved so far or the
  length recieved between the last time it was called and this time?

 The length of the buffer; the same as length($buffer).

  And lastly, what can be placed in HOOK_DATA - scalar only?)

 Yes, but the scalar can also be a ref to an array or hash.

  2) Is there any way of knowing how often the hook will get called?

 Not really- it's called when apache calls ap_get_client_block.

  3) Is there a specific phase of the Request that Apache::Request
  must be called and initialized with the callback before?

 The hooks get run as the data is uploaded to the server,
 which IOW is when the data is first being parsed.  This
 can happen at any phase you choose, but it only happens
 once per request.

  4) Are there any specific issues for using this with
  Apache::Request-instance ?

 Other than (3), I don't think so- but as I said before
 this is not a well-tested feature (yet :)

 HTH
 --
 Joe Schaefer





Re: Apache::Request UPLOAD_HOOK

2001-10-08 Thread Joe Schaefer

Issac Goldstand [EMAIL PROTECTED] writes:

 The documentation on how to use this feature is a bit sketchy... 

Yes, I agree. Doc patches are always welcome.  

Comments below are from memory since I last tested this feature 
about 6 months ago.

 Can anyone explain: 1) What the variables passed to the callback
 function are (looks like the Apache::Upload object is the first, but
 what's been filled in there when the hook gets called? 

The current upload object goes there when the hook is called.

 The second looks like the current bunch of data that's been
 recieved[?], 

Right, it's the buffer from apache's ap_get_client_block,
which is usually around 2-4 KB.  The hook runs before the
buffer gets written to the underlying tempfile, but as soon 
as your hook has completed, Apache::Request will write it 
automatically.

 the third is the length, but is that the length recieved so far or the
 length recieved between the last time it was called and this time?

The length of the buffer; the same as length($buffer).

 And lastly, what can be placed in HOOK_DATA - scalar only?)

Yes, but the scalar can also be a ref to an array or hash.

 2) Is there any way of knowing how often the hook will get called? 

Not really- it's called when apache calls ap_get_client_block.

 3) Is there a specific phase of the Request that Apache::Request 
 must be called and initialized with the callback before?  

The hooks get run as the data is uploaded to the server,
which IOW is when the data is first being parsed.  This
can happen at any phase you choose, but it only happens
once per request.

 4) Are there any specific issues for using this with
 Apache::Request-instance ?

Other than (3), I don't think so- but as I said before
this is not a well-tested feature (yet :)

HTH
-- 
Joe Schaefer