X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=http_filter_api.c;h=f7e99ec3a12c13bd488bc13468a62e55c37c1f5a;hp=1836b27d6b259cb362d3189985420932c15b5207;hb=32e91737086db53bb1fd9ed9f79d693c43ec459f;hpb=a19f558421040b5396b3d76e6c4878d7eda85aba diff --git a/http_filter_api.c b/http_filter_api.c index 1836b27..f7e99ec 100644 --- a/http_filter_api.c +++ b/http_filter_api.c @@ -6,7 +6,7 @@ | modification, are permitted provided that the conditions mentioned | | in the accompanying LICENSE file are met. | +--------------------------------------------------------------------+ - | Copyright (c) 2004-2005, Michael Wallner | + | Copyright (c) 2004-2006, Michael Wallner | +--------------------------------------------------------------------+ */ @@ -131,7 +131,7 @@ static HTTP_FILTER_FUNCTION(chunked_decode) if (PHPSTR_LEN(buffer) < buffer->hexlen) { /* flush anyway? */ - if (flags == PSFS_FLAG_FLUSH_INC) { + if (flags & PSFS_FLAG_FLUSH_INC) { /* flush all data (should only be chunk data) */ out_avail = 1; @@ -210,7 +210,7 @@ static HTTP_FILTER_FUNCTION(chunked_decode) } /* flush before close, but only if we are already waiting for more data */ - if (flags == PSFS_FLAG_FLUSH_CLOSE && buffer->hexlen && PHPSTR_LEN(buffer)) { + if ((flags & PSFS_FLAG_FLUSH_CLOSE) && buffer->hexlen && PHPSTR_LEN(buffer)) { out_avail = 1; NEW_BUCKET(PHPSTR_VAL(buffer), PHPSTR_LEN(buffer)); phpstr_reset(PHPSTR(buffer)); @@ -269,7 +269,7 @@ static HTTP_FILTER_FUNCTION(chunked_encode) } /* terminate with "0" */ - if (flags == PSFS_FLAG_FLUSH_CLOSE) { + if (flags & PSFS_FLAG_FLUSH_CLOSE) { out_avail = 1; NEW_BUCKET("0" HTTP_CRLF, lenof("0" HTTP_CRLF)); } @@ -329,7 +329,19 @@ static HTTP_FILTER_FUNCTION(deflate) } /* flush & close */ - if (flags == PSFS_FLAG_FLUSH_CLOSE) { + if (flags & PSFS_FLAG_FLUSH_INC) { + char *encoded = NULL; + size_t encoded_len = 0; + + http_encoding_deflate_stream_flush(buffer, &encoded, &encoded_len); + if (encoded) { + out_avail = 1; + NEW_BUCKET(encoded, encoded_len); + efree(encoded); + } + } + + if (flags & PSFS_FLAG_FLUSH_CLOSE) { char *encoded = NULL; size_t encoded_len = 0; @@ -382,7 +394,19 @@ static HTTP_FILTER_FUNCTION(inflate) } /* flush & close */ - if (flags == PSFS_FLAG_FLUSH_CLOSE) { + if (flags & PSFS_FLAG_FLUSH_INC) { + char *decoded = NULL; + size_t decoded_len = 0; + + http_encoding_inflate_stream_flush(buffer, &decoded, &decoded_len); + if (decoded) { + out_avail = 1; + NEW_BUCKET(decoded, decoded_len); + efree(decoded); + } + } + + if (flags & PSFS_FLAG_FLUSH_CLOSE) { char *decoded = NULL; size_t decoded_len = 0;