Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support ServerRequests #25

Open
mcorossigo opened this issue Feb 1, 2021 · 2 comments
Open

Support ServerRequests #25

mcorossigo opened this issue Feb 1, 2021 · 2 comments

Comments

@mcorossigo
Copy link

Since my last issue, I am working (and systematically failing BTW) on supporting ServerRequests in the same fashion of Requests so that I can feed it something like $request = GuzzleHttp\Psr7\ServerRequest::fromGlobals();

For docs: https://www.php-fig.org/psr/psr-7/#321-psrhttpmessageserverrequestinterface

Any comment/advice is welcome.

Thank you!

@deviantintegral
Copy link
Owner

It seems like you'd want to:

  1. Create a new method at \Deviantintegral\Har\Request::fromPsr7ServerRequest(ServerRequestInterface $source), mirroring \Deviantintegral\Har\Request::fromPsr7Request(). This would adapt a ServerRequest into something that can be represented in a HAR.
  2. Create a new class in src/Adapter/Psr7/ for a ServerRequest to adapt a HAR request back into a ServerRequest. You'll likely want to extend from \Deviantintegral\Har\Adapter\Psr7\MessageBase, implementing \Psr\Http\Message\RequestInterface, noting that we should clone the original object to prevent accidental changes to it like is done at \Deviantintegral\Har\Adapter\Psr7\Request::__construct().

Does that help? Feel free to open a PR as you work on this.

@mcorossigo
Copy link
Author

What I'am at:

  1. I copied \Deviantintegral\Har\Request to \Deviantintegral\Har\ServerRequest and made some adaptation (with also fromPsr7ServerRequest).
  2. Also already created the new adapter, but I'm desperately trying to avoid to have to implement ServerRequestInterface by extending GuzzleHttp\Psr7\ServerRequest. Unfortunately the datamodel is fairly different, so I might just go the way you suggested.

If you find value in the feature and want to take over the effort, feel free to implement it yourself any time. I'll open a PR if I get somewhere!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants