Skip to content

Commit 6212f3e

Browse files
authored
Merge pull request #522 from clue-labs/drop-ringcentral
Drop leftover RingCentral PSR-7 dependency, use own PSR-7 implementation
2 parents b5c98da + 30c802c commit 6212f3e

15 files changed

+19
-24
lines changed

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@
3333
"react/event-loop": "^1.2",
3434
"react/promise": "^3 || ^2.3 || ^1.2.1",
3535
"react/socket": "^1.12",
36-
"react/stream": "^1.2",
37-
"ringcentral/psr7": "^1.2"
36+
"react/stream": "^1.2"
3837
},
3938
"require-dev": {
4039
"clue/http-proxy-react": "^1.8",

examples/01-client-get-request.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
$client = new Browser();
99

1010
$client->get('http://google.com/')->then(function (ResponseInterface $response) {
11-
var_dump($response->getHeaders(), (string)$response->getBody());
11+
echo (string) $response->getBody();
1212
}, function (Exception $e) {
1313
echo 'Error: ' . $e->getMessage() . PHP_EOL;
1414
});

examples/02-client-concurrent-requests.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@
88
$client = new Browser();
99

1010
$client->head('http://www.github.com/clue/http-react')->then(function (ResponseInterface $response) {
11-
var_dump($response->getHeaders(), (string)$response->getBody());
11+
echo (string) $response->getBody();
1212
}, function (Exception $e) {
1313
echo 'Error: ' . $e->getMessage() . PHP_EOL;
1414
});
1515

1616
$client->get('http://google.com/')->then(function (ResponseInterface $response) {
17-
var_dump($response->getHeaders(), (string)$response->getBody());
17+
echo (string) $response->getBody();
1818
}, function (Exception $e) {
1919
echo 'Error: ' . $e->getMessage() . PHP_EOL;
2020
});
2121

2222
$client->get('http://www.lueck.tv/psocksd')->then(function (ResponseInterface $response) {
23-
var_dump($response->getHeaders(), (string)$response->getBody());
23+
echo (string) $response->getBody();
2424
}, function (Exception $e) {
2525
echo 'Error: ' . $e->getMessage() . PHP_EOL;
2626
});

examples/04-client-post-json.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
),
2323
json_encode($data)
2424
)->then(function (ResponseInterface $response) {
25-
echo (string)$response->getBody();
25+
echo (string) $response->getBody();
2626
}, function (Exception $e) {
2727
echo 'Error: ' . $e->getMessage() . PHP_EOL;
2828
});

examples/05-client-put-xml.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
),
2020
$xml->asXML()
2121
)->then(function (ResponseInterface $response) {
22-
echo (string)$response->getBody();
22+
echo (string) $response->getBody();
2323
}, function (Exception $e) {
2424
echo 'Error: ' . $e->getMessage() . PHP_EOL;
2525
});

examples/11-client-http-proxy.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
// demo fetching HTTP headers (or bail out otherwise)
2727
$browser->get('https://www.google.com/')->then(function (ResponseInterface $response) {
28-
echo RingCentral\Psr7\str($response);
28+
echo (string) $response->getBody();
2929
}, function (Exception $e) {
3030
echo 'Error: ' . $e->getMessage() . PHP_EOL;
3131
});

examples/12-client-socks-proxy.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
// demo fetching HTTP headers (or bail out otherwise)
2727
$browser->get('https://www.google.com/')->then(function (ResponseInterface $response) {
28-
echo RingCentral\Psr7\str($response);
28+
echo (string) $response->getBody();
2929
}, function (Exception $e) {
3030
echo 'Error: ' . $e->getMessage() . PHP_EOL;
3131
});

examples/13-client-ssh-proxy.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
// demo fetching HTTP headers (or bail out otherwise)
2323
$browser->get('https://www.google.com/')->then(function (ResponseInterface $response) {
24-
echo RingCentral\Psr7\str($response);
24+
echo (string) $response->getBody();
2525
}, function (Exception $e) {
2626
echo 'Error: ' . $e->getMessage() . PHP_EOL;
2727
});

examples/14-client-unix-domain-sockets.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
use React\Http\Browser;
55
use React\Socket\FixedUriConnector;
66
use React\Socket\UnixConnector;
7-
use RingCentral\Psr7;
87

98
require __DIR__ . '/../vendor/autoload.php';
109

@@ -18,7 +17,7 @@
1817

1918
// demo fetching HTTP headers (or bail out otherwise)
2019
$browser->get('http://localhost/info')->then(function (ResponseInterface $response) {
21-
echo Psr7\str($response);
20+
echo (string) $response->getBody();
2221
}, function (Exception $e) {
2322
echo 'Error: ' . $e->getMessage() . PHP_EOL;
2423
});

examples/21-client-request-streaming-to-stdout.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
use Psr\Http\Message\ResponseInterface;
55
use React\Stream\ReadableStreamInterface;
66
use React\Stream\WritableResourceStream;
7-
use RingCentral\Psr7;
87

98
require __DIR__ . '/../vendor/autoload.php';
109

@@ -22,7 +21,7 @@
2221
$info->write('Requesting ' . $url . '' . PHP_EOL);
2322

2423
$client->requestStreaming('GET', $url)->then(function (ResponseInterface $response) use ($info, $out) {
25-
$info->write('Received' . PHP_EOL . Psr7\str($response));
24+
$info->write('Received ' . $response->getStatusCode() . ' ' . $response->getReasonPhrase() . PHP_EOL);
2625

2726
$body = $response->getBody();
2827
assert($body instanceof ReadableStreamInterface);

examples/22-client-stream-upload-from-stdin.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
use Psr\Http\Message\ResponseInterface;
44
use React\Http\Browser;
55
use React\Stream\ReadableResourceStream;
6-
use RingCentral\Psr7;
76

87
require __DIR__ . '/../vendor/autoload.php';
98

@@ -20,7 +19,7 @@
2019
echo 'Sending STDIN as POST to ' . $url . '' . PHP_EOL;
2120

2221
$client->post($url, array('Content-Type' => 'text/plain'), $in)->then(function (ResponseInterface $response) {
23-
echo 'Received' . PHP_EOL . Psr7\str($response);
22+
echo (string) $response->getBody();
2423
}, function (Exception $e) {
2524
echo 'Error: ' . $e->getMessage() . PHP_EOL;
2625
});

examples/71-server-http-proxy.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
// left up as an exercise: use an HTTP client to send the outgoing request
2929
// and forward the incoming response to the original client request
3030
return React\Http\Message\Response::plaintext(
31-
RingCentral\Psr7\str($outgoing)
31+
$outgoing->getMethod() . ' ' . $outgoing->getRequestTarget() . ' HTTP/' . $outgoing->getProtocolVersion() . "\r\n\r\n" . (string) $outgoing->getBody()
3232
);
3333
});
3434

examples/91-client-benchmark-download.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@
2929
echo 'Requesting ' . $url . '' . PHP_EOL;
3030

3131
$client->requestStreaming('GET', $url)->then(function (ResponseInterface $response) {
32-
echo 'Headers received' . PHP_EOL;
33-
echo RingCentral\Psr7\str($response);
32+
echo 'Received ' . $response->getStatusCode() . ' ' . $response->getReasonPhrase() . PHP_EOL;
3433

3534
$stream = $response->getBody();
3635
assert($stream instanceof ReadableStreamInterface);

src/Io/ClientRequestStream.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,8 @@ public function close()
277277
*/
278278
public function hasMessageKeepAliveEnabled(MessageInterface $message)
279279
{
280-
$connectionOptions = \RingCentral\Psr7\normalize_header(\strtolower($message->getHeaderLine('Connection')));
280+
// @link https://www.rfc-editor.org/rfc/rfc9110#section-7.6.1
281+
$connectionOptions = \array_map('trim', \explode(',', \strtolower($message->getHeaderLine('Connection'))));
281282

282283
if (\in_array('close', $connectionOptions, true)) {
283284
return false;

tests/Middleware/RequestBodyBufferMiddlewareTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44

55
use Psr\Http\Message\ServerRequestInterface;
66
use React\EventLoop\Loop;
7+
use React\Http\Io\BufferedBody;
78
use React\Http\Io\HttpBodyStream;
89
use React\Http\Message\Response;
910
use React\Http\Message\ServerRequest;
1011
use React\Http\Middleware\RequestBodyBufferMiddleware;
1112
use React\Stream\ThroughStream;
1213
use React\Tests\Http\TestCase;
13-
use RingCentral\Psr7\BufferStream;
1414

1515
final class RequestBodyBufferMiddlewareTest extends TestCase
1616
{
@@ -45,8 +45,7 @@ public function testAlreadyBufferedResolvesImmediately()
4545
{
4646
$size = 1024;
4747
$body = str_repeat('x', $size);
48-
$stream = new BufferStream(1024);
49-
$stream->write($body);
48+
$stream = new BufferedBody($body);
5049
$serverRequest = new ServerRequest(
5150
'GET',
5251
'https://example.com/',

0 commit comments

Comments
 (0)