From: Ryan Bloom Date: Tue, 3 Oct 2000 00:44:00 +0000 (+0000) Subject: Replace ap_get_data_from_filter and ap_save_data_to_filter with X-Git-Tag: APACHE_2_0_ALPHA_7~71 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3d31ec804b6439b5f23ea036fbdd66a02ae6459d;p=apache Replace ap_get_data_from_filter and ap_save_data_to_filter with ap_save_brigade. This function does not try to save the actual brigade to a specific location. If just traverses the brigade, calls setaside if it is available and concatenates it with a previously setaside brigade. The resulting brigade is returned to the caller for them to save it to the appropriate location. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@86370 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/include/util_filter.h b/include/util_filter.h index 41b4cd914c..c7b20ba867 100644 --- a/include/util_filter.h +++ b/include/util_filter.h @@ -346,28 +346,19 @@ API_EXPORT(void) ap_add_filter(const char *name, void *ctx, request_rec *r); * you retrieve data, if you pass in a bucket brigade to the get function, * it will append the current brigade onto the one that you are retrieving. */ -/** - * Get data that was saved aside for the current filter from an earlier call - * @param f The current filter - * @param b The bucket brigade to append to the data that was saved earlier. - * This should be the brigade that was most recently passed to the - * filter - * @return A single bucket brigade containing all of the data that was set - * aside from a previous call to ap_save_data_to_filter and the data - * that was most recently passed to this filter. - * @deffunc ap_bucket_brigade *ap_get_saved_data(ap_filter_t *f, ap_bucket_brigade **b) - */ -API_EXPORT(ap_bucket_brigade *) ap_get_saved_data(ap_filter_t *f, - ap_bucket_brigade **b); /** - * Save a bucket brigade to a filter. This is used to save portions of the - * data off to the side for consumption later + * prepare a bucket brigade to be setaside. If a different brigade was + * set-aside earlier, then the two brigades are concatenated together. * @param f The current filter - * @param b The bucket brigade to save aside - * @deffunc void ap_save_data_to_filter(ap_filter_t *f, ap_bucket_brigade **b) + * @param save_to The brigade that was previously set-aside. Regardless, the + * new bucket brigade is returned in this location. + * @param b The bucket brigade to save aside. This brigade is always empty + * on return + * @deffunc void ap_save_brigade(ap_filter_t *f, ap_bucket_brigade **save_to, ap_bucket_brigade **b) */ -API_EXPORT(void) ap_save_data_to_filter(ap_filter_t *f, ap_bucket_brigade **b); +API_EXPORT(void) ap_save_brigade(ap_filter_t *f, ap_bucket_brigade **save_to, + ap_bucket_brigade **b); #ifdef __cplusplus } diff --git a/server/util_filter.c b/server/util_filter.c index 2b0ff6f29c..c7641c3c3f 100644 --- a/server/util_filter.c +++ b/server/util_filter.c @@ -209,48 +209,21 @@ API_EXPORT(apr_status_t) ap_pass_brigade(ap_filter_t *next, ap_bucket_brigade *b return AP_NOBODY_WROTE; } -API_EXPORT(ap_bucket_brigade *) ap_get_saved_data(ap_filter_t *f, - ap_bucket_brigade **b) +API_EXPORT(void) ap_save_brigade(ap_filter_t *f, ap_bucket_brigade **saveto, + ap_bucket_brigade **b) { - ap_bucket_brigade *bb = (ap_bucket_brigade *)f->ctx; - - /* If we have never stored any data in the filter, then we had better - * create an empty bucket brigade so that we can concat. - */ - if (!bb) { - bb = ap_brigade_create(f->r->pool); - } - - /* join the two brigades together. *b is now empty so we can - * safely destroy it. - */ - AP_BRIGADE_CONCAT(bb, *b); - ap_brigade_destroy(*b); - /* clear out the filter's context pointer. If we don't do this, then - * when we save more data to the filter, we will be appended to what is - * currently there. This will mean repeating data.... BAD! :-) - */ - f->ctx = NULL; - - return bb; -} - -API_EXPORT(void) ap_save_data_to_filter(ap_filter_t *f, ap_bucket_brigade **b) -{ - ap_bucket_brigade *bb = (ap_bucket_brigade *)f->ctx; ap_bucket *e; /* If have never stored any data in the filter, then we had better * create an empty bucket brigade so that we can concat. */ - if (!bb) { - bb = ap_brigade_create(f->r->pool); + if (!(*saveto)) { + *saveto = ap_brigade_create(f->r->pool); } AP_RING_FOREACH(e, &(*b)->list, ap_bucket, link) { if (e->setaside) e->setaside(e); } - AP_BRIGADE_CONCAT(bb, *b); - f->ctx = bb; + AP_BRIGADE_CONCAT(*saveto, *b); }