Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

ServerSentEventHttpMessageReader does not recognize data fields without a colon

Đang mở Phù hợp với người mới
#37,461 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

  • #37464 của @lejuho — đã đóng, không merge
  • #37508 của @Yusuf-Hussien — đã đóng, không merge

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
76/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
java, spring
Lĩnh vực
api, backend

Hướng nghiên cứu

Bắt đầu bằng cách đọc ServerSentEventHttpMessageReader và bài kiểm thử có thể tái hiện readServerSentEventsDataWithoutColon trong issue. Kiểm tra cách reader phân tích các dòng không có dấu hai chấm, sau đó chạy bài kiểm thử tập trung. Hoàn thành khi các trường dữ liệu không có dấu hai chấm tạo ra dữ liệu sự kiện mong đợi là "\n", giống như dạng có dấu hai chấm.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

in: web status: waiting-for-triage

ServerSentEventHttpMessageReader does not recognize SSE data fields when the colon is omitted:

id:c42
event:foo
data
data

or

id:c42
event:foo
data

According to the WHATWG HTML specification, a line without a colon must be processed as a field name with an empty value.
Therefore, data and data: should be treated equivalently.

Reproducible test case:

    @Test
    void readServerSentEventsDataWithoutColon() {
        // given
        ServerSentEventHttpMessageReader reader = new ServerSentEventHttpMessageReader();
        String body = """
                id:c42
                event:foo
                data
                data
                """;
        MockServerHttpRequest request = MockServerHttpRequest.post("/")
                .body(body);

        // when
        Flux<ServerSentEvent> events = reader.read(ResolvableType.forClassWithGenerics(ServerSentEvent.class, String.class), request, Collections.emptyMap())
                .cast(ServerSentEvent.class);

        // then - fails
        StepVerifier.create(events)
                .expectNext(ServerSentEvent.builder()
                        .id("c42")
                        .event("foo")
                        .data("\n")
                        .build())
                .expectComplete()
                .verify();
    }

Expected behavior

The reader should follow the WHATWG SSE parsing algorithm:
data\ndata should produce an event with data("\n"), just like data:\ndata:

Actual behavior

The implementation only handles data fields that start with data:
data\ndata produce an event with data(null)

Ngôn ngữ chính
Java
Star
60.3k
Fork
38.7k
Merge trung bình
1 ngày 9 giờ
Pull request đã merge (30 ngày)
34

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của spring-projects/spring-framework

Tất cả issue của spring-projects/spring-framework

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.