Skip to content

Conversation

@lboynton
Copy link

@lboynton lboynton commented Jul 8, 2016

Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Related tickets
Documentation if this is a new feature, link to pull request in https://github.com/php-http/documentation that adds relevant documentation TODO
License MIT

What's in this PR?

Adds a method to get the last request that was sent.

Why?

When using HttpMethodsClient to send requests, you do not generally create the request object itself. The method added here provides you with a way to access the request that was created when using methods such as get, post, patch etc. This can be useful for instance if you wish to look at the request that was sent for debugging or logging purposes.

Please let me know if you think there is a better way of achieving this, or if this is already possible.

Example Usage

use Http\Discovery\HttpClientDiscovery;
use Http\Discovery\MessageFactoryDiscovery

$client = new HttpMethodsClient(
    HttpClientDiscovery::find(),
    MessageFactoryDiscovery::find()
);

$foo = $client->get('http://example.com/foo');
$request = $client->getLastRequest(); // contains a GET request to http://example.com/foo

Checklist

  • Updated CHANGELOG.md to describe BC breaks / deprecations | new feature | bugfix
  • Documentation pull request created (if not simply a bugfix)

To Do

Nothing

When using this convenience client to send requests, you do not generally create the request object itself. The method added here provides you with a way to access the request that was created when using methods such as get, post, patch etc.
@Nyholm
Copy link
Member

Nyholm commented Jul 14, 2016

I've solved that issue with the HistoryPlugin and a Journal I wrote myself. I know this link is not the best one because the PR is massive... KnpLabs/php-github-api#389

@lboynton
Copy link
Author

Thanks that sounds like an interesting solution. I'll have to check if that
will work for me.
On 14 Jul 2016 08:36, "Tobias Nyholm" [email protected] wrote:

I've solved that issue with the HistoryPlugin and a Journal I wrote myself.
I know this link is not the best one because the PR is massive...
KnpLabs/php-github-api#389
KnpLabs/php-github-api#389


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#23 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AAGCOdcyT_tQIC-ldz2hBQI1JzLzj7u_ks5qVecYgaJpZM4JH_gf
.

@sagikazarmark
Copy link
Member

Is this still a thing? To be honest, I don't really like the idea to store the request in the client.

@dbu
Copy link
Contributor

dbu commented Jul 18, 2016

lets use a plugin when this is needed. the plugin would work with any client, not only with the HttpMethodsClient. thanks for contributing @lboynton - i hope its ok for you. and keep contributing if you have ideas!

@dbu dbu closed this Jul 18, 2016
@lboynton
Copy link
Author

Yep happy to close this.
On 18 Jul 2016 10:02, "David Buchmann" [email protected] wrote:

Closed #23 #23.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#23 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAGCOdYtQaoPDJ337uIqgZSlia78EEjmks5qWzL0gaJpZM4JH_gf
.

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

Successfully merging this pull request may close these issues.

4 participants