Add ForwardedForMiddleware
Add create prefix to static constructors
More docs
We never use Interface
in any interface names. We can still have BC breaks in the beta, especially for something as easy to fix as a name. So definitely Session
as the interface name, and… I dunno for the implementation, I'm terrible at naming things.
On second thought, static constructors
Single log message for request and response
Move header folding test to expected failures
Split SocketHttpServer
Fix test issues revealed after updating amphp/http-server
Update for "raw" to "pairs" rename
Update for amphp/http beta 2
Fix Psalm issues
More specifically, 8.1.15-16 and 8.2.2-3 have a GC bug that will segfault in a fiber, which was fixed in 8.1.17 and 8.2.4.
I was considering throwing an exception or triggering an error in the Revolt event loop if the affected versions are used since the application will segfault eventually.
Change "raw" to "pairs"
Allow calling Context::join() immediately
Include context backtrace in message (#168)
PHP does not call __toString()
on a previous exception, so our decision to wrap ContextPanicError
in a ContextException
had the unfortunate side-effect of removing the context trace from the output of an uncaught exception.
There's a couple ways we can approach this. This PR puts the trace as a string into the message. This has the side-effect of needing to create a stack-trace string for uncaught exceptions from Tasks
, but is mostly negligible I'd think.
Another approach would be to use reflection to set the $trace
property of the parent exception, forcing the child trace to be the trace of the ContextPanicError
object.
(new \ReflectionProperty(parent::class, 'trace'))->setValue($this, $originalTrace);
A closure provided to a Cancellation
should not throw. These functions are executed within the event loop, not within the context where they are defined. The Cancellation documentation doesn't make this clear, so I apologize for the confusion.
The cancellation subscriber should instead trigger some action that would then stop the operation and potentially throw from the original context, such as failing a deferred.
$deferred = new DeferredFuture();
$cancellation->subscribe(fn ($e) => $deferred->error($e));
return $deferred->await();
Many APIs can accept an optional Cancellation
, such as HttpClient::request()
in amphp/http-client
, eliminating the need to set up a subscriber yourself. delay()
is another such function. Your example could be simplified to:
class Job implements Task {
public function run(Channel $channel, Cancellation $cancellation): bool {
delay(2, cancellation: $cancellation); // fake work, longer than the timeout
return true;
}
}