httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stas Bekman <s...@stason.org>
Subject should input filter return the exact amount of bytes asked for?
Date Tue, 04 Nov 2003 09:41:46 GMT
I'm trying to get rid of ap_get_client_block(), but I don't understand a few 
things. ap_get_client_block() asks for readbytes from the upstream filter. 
What happens if the filter returns less bytes (while there is still more data 
coming?) What happens if the filter returns more bytes than requested (e.g. 
because it uncompressed some data). After all the incoming filters all 
propogate a request for N bytes read to the core_in filter, which returns that 
exact number if it can. Now as the data flows up the filter chain its length 
may change. Does it mean that if the filter didn't return the exact amount 
asked for it's broken? Is that the case when it returns less data than 
requested? Or when it returns more data?

I'm trying to deal with the case where a user call wants N bytes and I've to 
give that exact number in a single call. I'm not sure whether I should buffer 
things if I've got too much data or on the opposite ask for more bbs if I 
don't have enough data. Are there any modules I can look at to learn from?

The doc for ap_get_brigade doesn't say anything about ap_get_brigade 
satisfying 'readbytes' argument.


/**
  * Get the current bucket brigade from the next filter on the filter
  * stack.  The filter returns an apr_status_t value.  If the bottom-most
  * filter doesn't read from the network, then ::AP_NOBODY_READ is returned.
  * The bucket brigade will be empty when there is nothing left to get.
  * @param filter The next filter in the chain
  * @param bucket The current bucket brigade.  The original brigade passed
  *               to ap_get_brigade() must be empty.
  * @param mode   The way in which the data should be read
  * @param block  How the operations should be performed
  *               ::APR_BLOCK_READ, ::APR_NONBLOCK_READ
  * @param readbytes How many bytes to read from the next filter.
  */
AP_DECLARE(apr_status_t) ap_get_brigade(ap_filter_t *filter,
                                         apr_bucket_brigade *bucket,
                                         ap_input_mode_t mode,
                                         apr_read_type_e block,
                                         apr_off_t readbytes);

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


Mime
View raw message