Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c222875

Browse filesBrowse files
committed
Merge branch '6.4' into 7.0
* 6.4: fix merge fix syntax for PHP 7.2 [Security] Fix Danish translations [Messenger] Improve deadlock handling on `ack()` and `reject()` [DomCrawler] Encode html entities only if nessecary [Serializer] reset backed_enum priority, and re-prioritise translatable [Validator] Accept `Stringable` in `ExecutionContext::build/addViolation()` [Serializer] Ignore when using #[Ignore] on a non-accessor [Filesystem] Strengthen the check of file permissions in `dumpFile` [Serializer] Fix XML scalar to object denormalization [HttpClient][EventSourceHttpClient] Fix consuming SSEs with \r\n separator
2 parents 6e70473 + bdea420 commit c222875
Copy full SHA for c222875

File tree

Expand file treeCollapse file tree

2 files changed

+14
-8
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+14
-8
lines changed

‎EventSourceHttpClient.php

Copy file name to clipboardExpand all lines: EventSourceHttpClient.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public function request(string $method, string $url, array $options = []): Respo
121121
return;
122122
}
123123

124-
$rx = '/((?:\r\n|[\r\n]){2,})/';
124+
$rx = '/((?:\r\n){2,}|\r{2,}|\n{2,})/';
125125
$content = $state->buffer.$chunk->getContent();
126126

127127
if ($chunk->isLast()) {

‎Tests/EventSourceHttpClientTest.php

Copy file name to clipboardExpand all lines: Tests/EventSourceHttpClientTest.php
+13-7Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,14 @@
2727
*/
2828
class EventSourceHttpClientTest extends TestCase
2929
{
30-
public function testGetServerSentEvents()
30+
/**
31+
* @testWith ["\n"]
32+
* ["\r"]
33+
* ["\r\n"]
34+
*/
35+
public function testGetServerSentEvents(string $sep)
3136
{
32-
$data = <<<TXT
37+
$rawData = <<<TXT
3338
event: builderror
3439
id: 46
3540
data: {"foo": "bar"}
@@ -58,6 +63,7 @@ public function testGetServerSentEvents()
5863
id: 60
5964
data
6065
TXT;
66+
$data = str_replace("\n", $sep, $rawData);
6167

6268
$chunk = new DataChunk(0, $data);
6369
$response = new MockResponse('', ['canceled' => false, 'http_method' => 'GET', 'url' => 'http://localhost:8080/events', 'response_headers' => ['content-type: text/event-stream']]);
@@ -83,11 +89,11 @@ public function testGetServerSentEvents()
8389

8490
$expected = [
8591
new FirstChunk(),
86-
new ServerSentEvent("event: builderror\nid: 46\ndata: {\"foo\": \"bar\"}\n\n"),
87-
new ServerSentEvent("event: reload\nid: 47\ndata: {}\n\n"),
88-
new ServerSentEvent("event: reload\nid: 48\ndata: {}\n\n"),
89-
new ServerSentEvent("data: test\ndata:test\nid: 49\nevent: testEvent\n\n\n"),
90-
new ServerSentEvent("id: 50\ndata: <tag>\ndata\ndata: <foo />\ndata\ndata: </tag>\n\n"),
92+
new ServerSentEvent(str_replace("\n", $sep, "event: builderror\nid: 46\ndata: {\"foo\": \"bar\"}\n\n")),
93+
new ServerSentEvent(str_replace("\n", $sep, "event: reload\nid: 47\ndata: {}\n\n")),
94+
new ServerSentEvent(str_replace("\n", $sep, "event: reload\nid: 48\ndata: {}\n\n")),
95+
new ServerSentEvent(str_replace("\n", $sep, "data: test\ndata:test\nid: 49\nevent: testEvent\n\n\n")),
96+
new ServerSentEvent(str_replace("\n", $sep, "id: 50\ndata: <tag>\ndata\ndata: <foo />\ndata\ndata: </tag>\n\n")),
9197
];
9298
$i = 0;
9399

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.