Skip to content

Commit 4fa6c07

Browse files
committed
handle : as part of data after the initial :
1 parent d035ed2 commit 4fa6c07

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

unirest/src/main/java/kong/unirest/core/java/SseResponseHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ private ParsedLine parse(String line) {
7171
} else if (!line.contains(":")) {
7272
return new ParsedLine(line, "");
7373
} else {
74-
var spl = line.split(":");
74+
var spl = line.split(":", 2);
7575
return new ParsedLine(spl[0].trim(), spl[1]);
7676
}
7777
}

unirest/src/test/java/kong/unirest/core/java/SseResponseHandlerTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@ void sendSimpleEvent() {
6868
.assertEvent("", "", "foo");
6969
}
7070

71+
@Test
72+
void dataWithJson(){
73+
handle("data: \"foo\": 1", "");
74+
listener.assertEventCount(1)
75+
.assertEvent("", "", "\"foo\": 1");
76+
}
77+
7178
@Test
7279
void multipleDataElementEvent() {
7380
handle("data: YHOO",

0 commit comments

Comments
 (0)