Skip to content

Commit eb60f05

Browse files
committed
Changing the way we handle comments
1 parent 9b5ef60 commit eb60f05

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

contract-tests/src/bin/sse-test-api/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ struct Event {
8181
async fn status() -> impl Responder {
8282
web::Json(Status {
8383
capabilities: vec![
84+
"comments".to_string(),
8485
"headers".to_string(),
8586
"last-event-id".to_string(),
8687
"read-timeout".to_string(),

eventsource-client/src/event_parser.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,8 @@ impl EventParser {
235235

236236
if key == "comment" {
237237
event_data.comment = Some(value.to_string());
238+
seen_empty_line = true;
239+
break;
238240
} else if key == "event" {
239241
event_data.event_type = value.to_string()
240242
} else if key == "data" {
@@ -549,14 +551,14 @@ mod tests {
549551
require_pop_event(&mut parser, |e| assert_eq!(e.id, Some("3".into())));
550552
}
551553

552-
#[test_case(b":hello\n"; "with LF")]
553-
#[test_case(b":hello\r"; "with CR")]
554-
#[test_case(b":hello\r\n"; "with CRLF")]
555-
fn test_decode_chunks_comments_are_ignored(chunk: &'static [u8]) {
556-
let mut parser = EventParser::new();
557-
assert!(parser.process_bytes(Bytes::from(chunk)).is_ok());
558-
assert!(parser.get_event().is_none());
559-
}
554+
// #[test_case(b":hello\n"; "with LF")]
555+
// #[test_case(b":hello\r"; "with CR")]
556+
// #[test_case(b":hello\r\n"; "with CRLF")]
557+
// fn test_decode_chunks_comments_are_ignored(chunk: &'static [u8]) {
558+
// let mut parser = EventParser::new();
559+
// assert!(parser.process_bytes(Bytes::from(chunk)).is_ok());
560+
// assert!(parser.get_event().is_none());
561+
// }
560562

561563
#[test_case(&["data:", "hello\n\n"], event("message", "hello"); "data split")]
562564
#[test_case(&["data:hell", "o\n\n"], event("message", "hello"); "data truncated")]

0 commit comments

Comments
 (0)