Answer the question
In order to leave comments, you need to log in
Guzzle 6 Pool: sink and filename in fulfilled, how to get?
Please help with guzzle.
There is the following code
$requests = function ($total) use ($client) {
foreach($this->downloadLinks as $key => $link) {
preg_match('/([0-9]*)\.mp4/', $link, $matches);
$resource = getcwd().'/videos/'.$this->downloadPath.'/'.$matches[0];
yield function () use ($client, $link, $resource) {
return $client->getAsync($link, [
'sink' => $resource,
'proxy' => 'tcp://'.$this->proxies[ mt_rand(0, count($this->proxies)-1)]
]);
};
}
};
$pool = new Pool($this->browser, $requests(count($requests)), [
'concurrency' => $concurrency,
'fulfilled' => function ($response, $index) {
как тут получить имя скачанного фала?
},
'rejected' => function ($reason, $index) {
echo 'rejcted';
},
]);
$promise = $pool->promise();
$promise->wait();
Answer the question
In order to leave comments, you need to log in
I did it via middlewears docs.guzzlephp.org/en/latest/handlers-and-middlewa... I
added the necessary data to the Response and already in fulfilled I got them $request->getHeader('custom_header');
Or add an identifier to yield if you need to get something of your own.
Or look repsonse, there should be all the headers and etc.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question