@@ -37,7 +37,7 @@ A collection of framework-agnostic utilities for use with [PSR-7 Message impleme
37
37
38
38
** requires [ composer] ( https://getcomposer.org ) **
39
39
40
- ` composer.json ` (note: replace ` dev-main ` with a [ version boundary] ( https://getcomposer.org/doc/articles/versions.md ) , e.g. ` ^2.1 ` )
40
+ ` composer.json ` (note: replace ` dev-main ` with a [ version boundary] ( https://getcomposer.org/doc/articles/versions.md ) , e.g. ` ^2.2 ` )
41
41
``` json
42
42
{
43
43
"require" : {
@@ -48,6 +48,7 @@ A collection of framework-agnostic utilities for use with [PSR-7 Message impleme
48
48
```
49
49
Profit!
50
50
51
+
51
52
## Usage
52
53
53
54
### ` URLExtractor `
@@ -72,10 +73,10 @@ $request = $factory->createRequest('GET', 'https://t.co/ZSS6nVOcVp');
72
73
$urlExtractor->sendRequest($request); // -> response from the final location
73
74
74
75
// you can retrieve an array with all followed locations afterwards
75
- $responses = $this->http ->getResponses(); // -> ResponseInterface[]
76
+ $responses = $urlExtractor ->getResponses(); // -> ResponseInterface[]
76
77
77
78
// if you just want the URL of the final location, you can use the extract method:
78
- $url = $this->http ->extract('https://t.co/ZSS6nVOcVp'); // -> https://api.guildwars2.com/v2/build
79
+ $url = $urlExtractor ->extract('https://t.co/ZSS6nVOcVp'); // -> https://api.guildwars2.com/v2/build
79
80
```
80
81
81
82
### ` EchoClient `
@@ -118,6 +119,37 @@ $loggingClient = new LoggingClient($httpClient, $logger);
118
119
$loggingClient->sendRequest($request); // -> log to output given via logger
119
120
```
120
121
122
+ The output looks similar to the following (using [ monolog] ( https://github.com/Seldaek/monolog ) ):
123
+
124
+ ```
125
+ [2024-03-15 22:10:41][debug] LoggingClientTest:
126
+ ----HTTP-REQUEST----
127
+ GET /get HTTP/1.1
128
+ Host: httpbin.org
129
+
130
+
131
+ [2024-03-15 22:10:41][debug] LoggingClientTest:
132
+ ----HTTP-RESPONSE---
133
+ HTTP/1.1 200 OK
134
+ Date: Fri, 15 Mar 2024 21:10:40 GMT
135
+ Content-Type: application/json
136
+ Content-Length: 294
137
+ Connection: keep-alive
138
+ Server: gunicorn/19.9.0
139
+ Access-Control-Allow-Origin: *
140
+ Access-Control-Allow-Credentials: true
141
+
142
+ {
143
+ "args": {},
144
+ "headers": {
145
+ "Host": "httpbin.org",
146
+ "User-Agent": "chillerlanPHPUnitHttp/1.0.0 +https://github.com/chillerlan/phpunit-http",
147
+ "X-Amzn-Trace-Id": "Root=1-65f4b950-1f87b9e37182673438091aea"
148
+ },
149
+ "origin": "93.236.207.163",
150
+ "url": "https://httpbin.org/get"
151
+ }
152
+ ```
121
153
122
154
123
155
## API
0 commit comments