@@ -117,6 +117,8 @@ class HttpClient {
117
117
bool websocket = false ; // if upgrade successfully
118
118
bool chunked = false ; // Transfer-Encoding: chunked
119
119
bool websocket_mask = true ; // enable websocket mask
120
+ bool body_decompression = true ;
121
+ bool http_compression = true ;
120
122
#ifdef SW_HAVE_ZLIB
121
123
bool websocket_compression = false ; // allow to compress websocket messages
122
124
#endif
@@ -541,7 +543,7 @@ static int http_parser_on_headers_complete(swoole_http_parser *parser) {
541
543
static int http_parser_on_body (swoole_http_parser *parser, const char *at, size_t length) {
542
544
HttpClient *http = (HttpClient *) parser->data ;
543
545
#ifdef SW_HAVE_COMPRESSION
544
- if (!http->compression_error && http->compress_method != HTTP_COMPRESS_NONE) {
546
+ if (http-> body_decompression && !http->compression_error && http->compress_method != HTTP_COMPRESS_NONE) {
545
547
if (!http->decompress_response (at, length)) {
546
548
http->compression_error = true ;
547
549
goto _append_raw;
@@ -774,6 +776,12 @@ void HttpClient::apply_setting(zval *zset, const bool check_all) {
774
776
if (php_swoole_array_get_value (vht, " websocket_mask" , ztmp)) {
775
777
websocket_mask = zval_is_true (ztmp);
776
778
}
779
+ if (php_swoole_array_get_value (vht, " http_compression" , ztmp)) {
780
+ http_compression = zval_is_true (ztmp);
781
+ }
782
+ if (php_swoole_array_get_value (vht, " body_decompression" , ztmp)) {
783
+ body_decompression = zval_is_true (ztmp);
784
+ }
777
785
#ifdef SW_HAVE_ZLIB
778
786
if (php_swoole_array_get_value (vht, " websocket_compression" , ztmp)) {
779
787
websocket_compression = zval_is_true (ztmp);
@@ -1060,7 +1068,7 @@ bool HttpClient::send() {
1060
1068
}
1061
1069
}
1062
1070
#ifdef SW_HAVE_COMPRESSION
1063
- if (!(header_flag & HTTP_HEADER_ACCEPT_ENCODING)) {
1071
+ if (http_compression && !(header_flag & HTTP_HEADER_ACCEPT_ENCODING)) {
1064
1072
add_headers (buffer,
1065
1073
ZEND_STRL (" Accept-Encoding" ),
1066
1074
#if defined(SW_HAVE_ZLIB) && defined(SW_HAVE_BROTLI)
0 commit comments