Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http-server http_compression = false invalid #3256

Closed
onanying opened this issue Apr 19, 2020 · 1 comment · Fixed by #3257
Closed

http-server http_compression = false invalid #3256

onanying opened this issue Apr 19, 2020 · 1 comment · Fixed by #3257

Comments

@onanying
Copy link
Contributor

onanying commented Apr 19, 2020

Please answer these questions before submitting your issue. Thanks!

  1. What did you do? If possible, provide a simple script for reproducing the error.

当我想强制不使用 compress 时,即便 header 内客户端提供了 Accept-Encoding ,因为我配置了 'http_compression' => false 都应该不执行压缩。这个在做微服务代理处理的时候我们需要关闭自动压缩。

<?php

function run($func)
{
    $scheduler = new \Swoole\Coroutine\Scheduler;
    $scheduler->set([
        'hook_flags' => SWOOLE_HOOK_ALL,
    ]);
    $scheduler->add(function () use ($func) {
        call_user_func($func);
    });
    $scheduler->start();
}

run(function(){
    $server = new \Swoole\Coroutine\Http\Server('0.0.0.0',9999);
    $server->set([
        'http_compression'    => false,
    ]);
    $server->handle('/', function ($requ, $resp) {
        $resp->end('hello');
    });
    go(function() use ($server) {
        $server->start();
    });
    $cli = new \Swoole\Coroutine\Http\Client('127.0.0.1', 9999);
    $cli->get('/');
    var_dump($cli->getHeaders());
});
array(6) {
  ["server"]=>
  string(18) "swoole-http-server"
  ["connection"]=>
  string(10) "keep-alive"
  ["content-type"]=>
  string(9) "text/html"
  ["date"]=>
  string(29) "Sun, 19 Apr 2020 15:02:20 GMT"
  ["content-length"]=>
  string(2) "25"
  ["content-encoding"]=>
  string(4) "gzip"
}
  1. What did you expect to see?

  2. What did you see instead?

  3. What version of Swoole are you using (show your php --ri swoole)?


swoole

Swoole => enabled
Author => Swoole Team <[email protected]>
Version => 4.4.17
Built => Apr 10 2020 18:30:47
coroutine => enabled
kqueue => enabled
rwlock => enabled
openssl => OpenSSL 1.1.1d  10 Sep 2019
http2 => enabled
pcre => enabled
zlib => 1.2.11
async_redis => enabled

Directive => Local Value => Master Value
swoole.enable_coroutine => On => On
swoole.enable_library => On => On
swoole.enable_preemptive_scheduler => Off => Off
swoole.display_errors => On => On
swoole.use_shortname => On => On
swoole.unixsock_buffer_size => 262144 => 262144
  1. What is your machine environment used (including version of kernel & php & gcc) ?
@twose
Copy link
Member

twose commented Apr 20, 2020

Fixed via #3257

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants