【发布时间】:2017-09-17 20:27:51
【问题描述】:
发出异步请求时,我无法更改请求标头。
$requests = function ($total) {
$uri = 'https://www.example.com';
$headers = [
'User-Agent' => 'testing/1.0',
'Accept' => 'application/json',
'X-Foo' => ['Bar', 'Baz']
];
for ($i = 0; $i < $total; $i++) {
yield new Request('GET', $uri, $headers); //Does not work
}
};
$pool = new Pool($client, $requests(2), [
'concurrency' => 5,
'fulfilled' => function ($response, $index) {
// this is delivered each successful response
},
'rejected' => function ($reason, $index) {
// this is delivered each failed request
},
]);
我相信我已经尝试了documentation 中提供的所有示例,并且能够更改除并发示例之外的所有示例的标题。任何帮助,将不胜感激。
【问题讨论】:
-
我知道这篇文章到现在已经 2 岁了,但我发现自己有同样的问题
-
抱歉,我不确定我是怎么做到的。我知道这个网站没有任何帮助。结帐 reddit。
标签: php concurrency guzzle guzzle6