#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
-#include "php.h"
-
-#include "php_http_encoding_api.h"
#include "php_http.h"
-#include "php_http_api.h"
-#ifdef HTTP_HAVE_ZLIB
-# include "php_http_send_api.h"
-# include "php_http_headers_api.h"
-# include <zlib.h>
-#endif
+#include "php_http_api.h"
+#include "php_http_encoding_api.h"
+#include "php_http_send_api.h"
+#include "php_http_headers_api.h"
ZEND_EXTERN_MODULE_GLOBALS(http);
http_init_gzencode_buffer(&Z, data, data_len, encoded);
- if ( (Z_OK == (status = deflateInit2(&Z, level, Z_DEFLATED, -MAX_WBITS, MAX_MEM_LEVEL, Z_DEFAULT_STRATEGY))) &&
- (Z_STREAM_END == (status = deflate(&Z, Z_FINISH))) &&
- (Z_OK == (status = deflateEnd(&Z)))) {
- *encoded_len = http_finish_gzencode_buffer(&Z, data, data_len, encoded);
- return SUCCESS;
+ if (Z_OK == (status = deflateInit2(&Z, level, Z_DEFLATED, -MAX_WBITS, MAX_MEM_LEVEL, Z_DEFAULT_STRATEGY))) {
+ status = deflate(&Z, Z_FINISH);
+ deflateEnd(&Z);
+
+ if (Z_STREAM_END == status) {
+ *encoded_len = http_finish_gzencode_buffer(&Z, data, data_len, encoded);
+ return SUCCESS;
+ }
}
efree(*encoded);
http_init_deflate_buffer(&Z, data, data_len, encoded);
- if ( (Z_OK == (status = deflateInit2(&Z, level, Z_DEFLATED, -MAX_WBITS, MAX_MEM_LEVEL, Z_DEFAULT_STRATEGY))) &&
- (Z_STREAM_END == (status = deflate(&Z, Z_FINISH))) &&
- (Z_OK == (status = deflateEnd(&Z)))) {
- *encoded_len = http_finish_buffer(Z.total_out, encoded);
- return SUCCESS;
+ if (Z_OK == (status = deflateInit2(&Z, level, Z_DEFLATED, -MAX_WBITS, MAX_MEM_LEVEL, Z_DEFAULT_STRATEGY))) {
+ status = deflate(&Z, Z_FINISH);
+ deflateEnd(&Z);
+
+ if (Z_STREAM_END == status) {
+ *encoded_len = http_finish_buffer(Z.total_out, encoded);
+ return SUCCESS;
+ }
}
efree(encoded);
do {
http_init_inflate_buffer(&Z, data, data_len, decoded, decoded_len, &max);
if (Z_OK == (status = inflateInit2(&Z, -MAX_WBITS))) {
- if (Z_STREAM_END == (status = inflate(&Z, Z_FINISH))) {
- if (Z_OK == (status = inflateEnd(&Z))) {
- *decoded_len = http_finish_buffer(Z.total_out, decoded);
- return SUCCESS;
- }
+ status = inflate(&Z, Z_FINISH);
+ inflateEnd(&Z);
+
+ if (Z_STREAM_END == status) {
+ *decoded_len = http_finish_buffer(Z.total_out, decoded);
+ return SUCCESS;
}
}
} while (++max < HTTP_ENCODING_MAXTRY && status == Z_BUF_ERROR);