Skip to content

Commit 7dfda7f

Browse files
committed
Update Socket to send secure HTTPS requests with PHP < 7.1.4
1 parent 7de47c7 commit 7dfda7f

File tree

2 files changed

+57
-2
lines changed

2 files changed

+57
-2
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
"php": ">=5.4.0",
88
"guzzlehttp/psr7": "^1.0",
99
"react/event-loop": "^1.0 || ^0.5 || ^0.4 || ^0.3",
10-
"react/socket": "^1.0 || ^0.8.2",
11-
"react/stream": "^1.0 || ^0.7 || ^0.6 || ^0.5 || ^0.4.2",
10+
"react/socket": "^1.0 || ^0.8.3",
11+
"react/stream": "^1.0 || ^0.7.1",
1212
"react/promise": "~2.2",
1313
"evenement/evenement": "^3.0 || ^2.0"
1414
},

tests/FunctionalIntegrationTest.php

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,61 @@ public function testSuccessfulResponseEmitsEnd()
4646
$loop->run();
4747
}
4848

49+
/** @group internet */
50+
public function testPostDataReturnsData()
51+
{
52+
$loop = Factory::create();
53+
$client = new Client($loop);
54+
55+
$data = str_repeat('.', 33000);
56+
$request = $client->request('POST', 'https://httpbin.org/post', array('Content-Length' => strlen($data)));
57+
58+
$buffer = '';
59+
$request->on('response', function (Response $response) use (&$buffer) {
60+
$response->on('data', function ($chunk) use (&$buffer) {
61+
$buffer .= $chunk;
62+
});
63+
});
64+
65+
$request->end($data);
66+
67+
$loop->run();
68+
69+
$this->assertNotEquals('', $buffer);
70+
71+
$parsed = json_decode($buffer, true);
72+
$this->assertTrue(is_array($parsed) && isset($parsed['data']));
73+
$this->assertEquals(strlen($data), strlen($parsed['data']));
74+
$this->assertEquals($data, $parsed['data']);
75+
}
76+
77+
/** @group internet */
78+
public function testPostJsonReturnsData()
79+
{
80+
$loop = Factory::create();
81+
$client = new Client($loop);
82+
83+
$data = json_encode(array('numbers' => range(1, 50)));
84+
$request = $client->request('POST', 'https://httpbin.org/post', array('Content-Length' => strlen($data), 'Content-Type' => 'application/json'));
85+
86+
$buffer = '';
87+
$request->on('response', function (Response $response) use (&$buffer) {
88+
$response->on('data', function ($chunk) use (&$buffer) {
89+
$buffer .= $chunk;
90+
});
91+
});
92+
93+
$request->end($data);
94+
95+
$loop->run();
96+
97+
$this->assertNotEquals('', $buffer);
98+
99+
$parsed = json_decode($buffer, true);
100+
$this->assertTrue(is_array($parsed) && isset($parsed['json']));
101+
$this->assertEquals(json_decode($data, true), $parsed['json']);
102+
}
103+
49104
/** @group internet */
50105
public function testCancelPendingConnectionEmitsClose()
51106
{

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy