| modification, are permitted provided that the conditions mentioned |
| in the accompanying LICENSE file are met. |
+--------------------------------------------------------------------+
- | Copyright (c) 2004-2005, Michael Wallner <mike@php.net> |
+ | Copyright (c) 2004-2006, Michael Wallner <mike@php.net> |
+--------------------------------------------------------------------+
*/
/* $Id$ */
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#define HTTP_WANT_ZLIB
#include "php_http.h"
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;
}
/* 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));
}
/* 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));
}
}
/* 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;
}
/* 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;