Skip to content

Commit 7ada041

Browse files
authored
Merge pull request #2 from wp-oop/feature/add-streaming
Add streaming
2 parents b21994f + 1f7fed7 commit 7ada041

File tree

8 files changed

+342
-62
lines changed

8 files changed

+342
-62
lines changed

.idea/http-client.iml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/php.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
99
## [0.1.0-alpha1] - 2023-08-18
1010
### Added
1111
- `Client` implementation, with tests (#1).
12+
- Streaming mode that uses a proxy file (#2).

README.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,21 @@ use Psr\Http\Message\ResponseFactoryInterface;
1515
use WpOop\HttpClient\Client;
1616

1717
/** @var RequestFactoryInterface $requestFactory */
18-
/** @var ResponseFactoryInterface $responseFacory */
18+
/** @var ResponseFactoryInterface $responseFactory */
1919

2020
// Set up the client with WP request options
2121
// https://developer.wordpress.org/reference/classes/wp_http/request/
22-
$client = new Client([
23-
'redirection' => 2,
24-
'timeout' => 60,
25-
], $responseFacory);
22+
$client = new Client(
23+
// Default args to WP_Http::request()
24+
[
25+
'redirection' => 2,
26+
'timeout' => 60,
27+
],
28+
$responseFactory,
29+
// Path to proxy file dir to enable response streaming.
30+
// If null, will buffer in memory instead.
31+
get_temp_dir()
32+
);
2633

2734
// Create a PSR-7 request in any way you want, for example via a PSR-17 factory
2835
$request = $requestFactory->createRequest('GET', 'http://somesite.com/api');

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"johnpbloch/wordpress-core": "6.3",
2525
"php-stubs/wordpress-stubs": "6.3",
2626
"nyholm/psr7": "^1.7",
27-
"brain/monkey": "^2.6.1"
27+
"brain/monkey": "^2.6.1",
28+
"mikey179/vfsstream": "^1.6.11"
2829
},
2930
"suggest": {
3031
"nyholm/psr7": "A slim and efficient PSR-7 and PSR-17 implementation"

composer.lock

Lines changed: 81 additions & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)