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

hook_flags 开启SWOOLE_HOOK_CURL后返回结果会自动在终端打印出来 #3799

Closed
bingcool opened this issue Nov 2, 2020 · 1 comment

Comments

@bingcool
Copy link

bingcool commented Nov 2, 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.

include "../vendor/autoload.php";

$http = new swoole_http_server("0.0.0.0", 9509);
$http->set([
'reactor_num' => 2,
'worker_num' => 1,
'max_request' => 100000,
'task_tmpdir' => '/dev/shm',
'reload_async' => true,
'daemonize' => 0,
'enable_coroutine' => 1,
'hook_flags' => SWOOLE_HOOK_ALL | SWOOLE_HOOK_CURL
]);

$http->on('workerStart', function ($serv, $id) {
$client = new \GuzzleHttp\Client();
$url = 'http://www.baidu.com';
/**
* 开启了SWOOLE_HOOK_CURL后,使用\GuzzleHttp\Client->request(),直接就会在终端打印出返回的数据了,没有使用var_dump也会自动打印出来response.
* 不开启SWOOLE_HOOK_CURL则没有问题
*/
$res = $client->request('GET', $url);
});

$http->on('request', function ($request, Swoole\Http\Response $response) use ($http) {
if($request->server['path_info'] == '/favicon.ico' || $request->server['request_uri'] == '/favicon.ico') {
$response->end();
return;
}

});

$http->start();

  1. What did you expect to see?

不希望调用$res = $client->request('GET', $url);就在终端自动打印出返回的res.

不开启SWOOLE_HOOK_CURL则没有问题

  1. What did you see instead?
    现在程序没有调用var_dump, 但却自动打印出返回的res

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

swoole

Swoole => enabled
Author => Swoole Team [email protected]
Version => 4.5.5
Built => Oct 31 2020 19:36:01
coroutine => enabled
epoll => enabled
eventfd => enabled
signalfd => enabled
spinlock => enabled
rwlock => enabled
pcre => enabled
zlib => 1.2.11
mutex_timedlock => enabled
pthread_barrier => enabled
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 => 8388608 => 8388608

  1. What is your machine environment used (show your uname -a & php -v & gcc -v) ?

6bcd0d6d19c6:/home/bingcool/wwwroot/workerfy/tests#uname -a
Linux 6bcd0d6d19c6 4.9.184-linuxkit #1 SMP Tue Jul 2 22:58:16 UTC 2019 x86_64 Linux

PHP 7.3.19 (cli) (built: Jun 12 2020 12:27:37) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.19, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.3.19, Copyright (c) 1999-2018, by Zend Technologies
[2]+ Done(127) $(...)

6bcd0d6d19c6:/home/bingcool/wwwroot/workerfy/tests#gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-alpine-linux-musl/9.3.0/lto-wrapper
Target: x86_64-alpine-linux-musl
Configured with: /home/buildozer/aports/main/gcc/src/gcc-9.3.0/configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --build=x86_64-alpine-linux-musl --host=x86_64-alpine-linux-musl --target=x86_64-alpine-linux-musl --with-pkgversion='Alpine 9.3.0' --enable-checking=release --disable-fixed-point --disable-libstdcxx-pch --disable-multilib --disable-nls --disable-werror --disable-symvers --enable-__cxa_atexit --enable-default-pie --enable-default-ssp --enable-cloog-backend --enable-languages=c,c++,d,objc,fortran,ada --disable-libssp --disable-libmpx --disable-libmudflap --disable-libsanitizer --enable-shared --enable-threads --enable-tls --with-system-zlib --with-linker-hash-style=gnu
Thread model: posix
gcc version 9.3.0 (Alpine 9.3.0)

@twose
Copy link
Member

twose commented Nov 2, 2020

[自动回复] 为了中文搜索引擎收录以便于后人检索和Github各国友人参与理解所需,本repo只接受英文issue

中文issue请前往Swoole中文问答社区

谢谢合作!

@twose twose closed this as completed Nov 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants