You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description
Imagine you have the guzzle client middleware that logs the requests somewhere to DB
In addition to the request itself, you need some arbitrary data to be logged, like UserID
It will be nice to be able to pass the object of the class, that extends RequestInterface with this additional UserId data and use the middleware that will take this additional data and log the request.
Unfortunately, \GuzzleHttp\Psr7\Utils::modifyRequest instead of modifying the request object, creates a new instance of \GuzzleHttp\Psr7\Request::__construct, so the middleware will receive this new instance, without this arbitrary data, instead of the original, but modified request.
It looks like it is possible to modify the function to operate on the request itself using
Description
Imagine you have the guzzle client middleware that logs the requests somewhere to DB
In addition to the request itself, you need some arbitrary data to be logged, like UserID
It will be nice to be able to pass the object of the class, that extends RequestInterface with this additional UserId data and use the middleware that will take this additional data and log the request.
Unfortunately, \GuzzleHttp\Psr7\Utils::modifyRequest instead of modifying the request object, creates a new instance of \GuzzleHttp\Psr7\Request::__construct, so the middleware will receive this new instance, without this arbitrary data, instead of the original, but modified request.
It looks like it is possible to modify the function to operate on the request itself using
$request->withoutHeader
$request->withHeader
$request->withMethod
$request->withUri
$request->withBody
$request->withProtocolVersion
mutators instead of creating new object.
I'm eager to write this change and create the PR, but I'd like to double-check first if this approach is valid or if I'm missing something.
The text was updated successfully, but these errors were encountered: