@@ -228,12 +228,12 @@ static apr_status_t redirectionio_filter_header_filtering(ap_filter_t *f, apr_bu
228
228
}
229
229
230
230
static apr_status_t redirectionio_filter_body_filtering (ap_filter_t * f , apr_bucket_brigade * bb ) {
231
- redirectionio_context * ctx = (redirectionio_context * )f -> ctx ;
232
- apr_bucket * b , * b_new ;
233
- apr_bucket_brigade * bb_new ;
234
- const char * input , * output , * input_str ;
235
- int64_t input_size , output_size ;
236
- apr_status_t rv ;
231
+ redirectionio_context * ctx = (redirectionio_context * )f -> ctx ;
232
+ apr_bucket * b , * b_new ;
233
+ apr_bucket_brigade * bb_new ;
234
+ const char * input_bucket ;
235
+ struct REDIRECTIONIO_Buffer input , output ;
236
+ apr_status_t rv ;
237
237
238
238
if (ctx == NULL ) {
239
239
return ap_pass_brigade (f -> next , bb );
@@ -266,7 +266,7 @@ static apr_status_t redirectionio_filter_body_filtering(ap_filter_t *f, apr_buck
266
266
// filter brigade
267
267
while (b != APR_BRIGADE_SENTINEL (bb )) {
268
268
// Read bucket
269
- rv = apr_bucket_read (b , & input , (apr_size_t * )& input_size , APR_BLOCK_READ );
269
+ rv = apr_bucket_read (b , & input_bucket , (apr_size_t * )& input . len , APR_BLOCK_READ );
270
270
271
271
if (rv != APR_SUCCESS ) {
272
272
redirectionio_action_body_filter_drop (ctx -> body_filter );
@@ -276,26 +276,16 @@ static apr_status_t redirectionio_filter_body_filtering(ap_filter_t *f, apr_buck
276
276
return ap_pass_brigade (f -> next , bb );
277
277
}
278
278
279
- // Send bucket
280
- if (input_size > 0 ) {
281
- input_str = strndup (input , input_size );
282
- output = redirectionio_action_body_filter_filter (ctx -> body_filter , input_str );
283
-
284
- if (output != input_str ) {
285
- free ((char * )input_str );
286
- }
279
+ input .data = malloc (input .len );
280
+ memcpy (input .data , input_bucket , input .len );
287
281
288
- if (output == NULL ) {
289
- ap_remove_output_filter (f );
290
-
291
- return ap_pass_brigade (f -> next , bb );
292
- }
293
-
294
- output_size = strlen (output );
282
+ // Send bucket
283
+ if (input .len > 0 ) {
284
+ output = redirectionio_action_body_filter_filter (ctx -> body_filter , input );
295
285
296
286
// Create a new one
297
- if (output_size > 0 ) {
298
- b_new = apr_bucket_transient_create (output , output_size , f -> r -> connection -> bucket_alloc );
287
+ if (output . len > 0 ) {
288
+ b_new = apr_bucket_transient_create (( const char * ) output . data , output . len , f -> r -> connection -> bucket_alloc );
299
289
300
290
if (b_new == NULL ) {
301
291
ap_remove_output_filter (f );
@@ -311,17 +301,9 @@ static apr_status_t redirectionio_filter_body_filtering(ap_filter_t *f, apr_buck
311
301
if (APR_BUCKET_IS_EOS (b )) {
312
302
output = redirectionio_action_body_filter_close (ctx -> body_filter );
313
303
314
- if (output == NULL ) {
315
- ap_remove_output_filter (f );
316
-
317
- return ap_pass_brigade (f -> next , bb );
318
- }
319
-
320
- output_size = strlen (output );
321
-
322
- if (output_size > 0 ) {
304
+ if (output .len > 0 ) {
323
305
// Create a new one
324
- b_new = apr_bucket_transient_create (output , output_size , f -> r -> connection -> bucket_alloc );
306
+ b_new = apr_bucket_transient_create (( const char * ) output . data , output . len , f -> r -> connection -> bucket_alloc );
325
307
326
308
if (b_new == NULL ) {
327
309
ap_remove_output_filter (f );
0 commit comments