Comments (8)
Thank you for the report!
from ext-http.
Looks like I'll have to disable/forbid resetting/dequeuing in the debug callback.
from ext-http.
Unfortunately, the problem occurs even in a more complex case with the request termination outside the setDebug() method.
<?php
class HTTPTransferObserver implements SplObserver {
public function update(SplSubject $client, http\Client\Request $request = null, stdclass $progress = null)
{
return;
}
public function cancelRequest(http\Client $client, http\Client\Request $request, int $type, string $data)
{
if ($type & http\Client::DEBUG_HEADER) {
$client->reset();
}
}
}
$c = new http\Client;
$c->enqueue($request = new http\Client\Request("GET", "https://m6w6.name"));
$observer = new HTTPTransferObserver($request);
$c->attach($observer);
$c->setDebug(function(http\Client $c, http\Client\Request $r, int $type, string $data) {
foreach ($c->getObservers() as $observer) {
$observer->cancelRequest($c, $r, $type, $data);
}
});
$c->send();
from ext-http.
We tried to reconstruct the problem with an C code example of curl (curl/docs/examples/http2-download.c) whereby the issue didn't appear.
from ext-http.
Your first example is still resetting/dequeuing while the callback is running.
The second example doesn't do all the things that are done otherwise, like curl_multi_remove_handle
etc.
The problem apparently is, that we invalidate the easy handle on reset/dequeue while libcurl is still operating on that handle when we return from the callback.
from ext-http.
It would be a pity to lose this feature, but perhaps you have another idea how we could solve the problem?
from ext-http.
@bagder just verified that it's probalby unsafe to call curl_multi_remove_handle from within the callback, so I tried to put something together, that would help you anyway:
$c = new http\Client;
$c->enqueue(new http\Client\Request("GET", "http://example.com"));
$c->setDebug(function($client, $request, $type, $data) use (&$dequeue) {
if (!$type) {
printf("D: %d <%s>\n", $type, $data);
if (sscanf($data, "\tTrying %s...", $ip)) {
printf("Blocking %s\n", $ip);
$dequeue[] = $request;
}
}
});
while ($c->once()) {
while ($dequeue) {
$c->dequeue(array_shift($dequeue));
}
$c->wait();
}
HTH
from ext-http.
thx, that helps!
from ext-http.
Related Issues (20)
- Build failure `fatal error: 'ext/raphf/php_raphf_api.h' file not found` HOT 1
- pecl install pecl_http error on mac OS catalina HOT 6
- Git merge conflict in the source code HOT 2
- Compilation Error HOT 1
- Build error with php 7.4.13 on master and v4.0.0beta1 HOT 1
- Parsing url with unicode characters HOT 2
- PHP 8.0 - Windows 10 x64 - Unable to load dynamic library 'http' HOT 1
- BROTLI lib version not displayed HOT 5
- PHP 8.1: Implement __serialize() and __unserialize() HOT 3
- Test failure since libcurl 7.77 HOT 2
- ext-http delays PHP startup by 5 seconds on macOS HOT 18
- Test failure with 8.1.0beta3
- HTTPS does not seem to work on Windows? HOT 17
- Segfault with libcurl 7.81 HOT 4
- Cookie tests fail for 3.2.5 on CentOS 7 with custom-built php/curl HOT 3
- Installing on FreeBSD after 4.2.1 HOT 3
- Can not install in PHP 8.2 Alpine docker image HOT 1
- Windows; extension loaded but offers no functions? HOT 5
- Test failing with libcurl 8.0 HOT 1
- .ddl for php 8.2 ? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ext-http.