From d1b609a084e28a358cc38acad6f415b0d4a135e5 Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Wed, 2 Apr 2025 21:33:22 +0900 Subject: [PATCH] Fix broken link for Server-Sent Events Closes gh-34704 Signed-off-by: Taeik Lim --- .../modules/ROOT/pages/web/webmvc-functional.adoc | 2 +- .../modules/ROOT/pages/web/webmvc/mvc-ann-async.adoc | 2 +- .../src/main/java/org/springframework/http/MediaType.java | 5 +++-- .../org/springframework/http/codec/ServerSentEvent.java | 5 +++-- .../web/reactive/function/BodyInserters.java | 3 ++- .../web/servlet/function/ServerResponse.java | 7 ++++--- .../web/servlet/function/SseServerResponse.java | 3 ++- .../web/servlet/mvc/method/annotation/SseEmitter.java | 5 +++-- .../transport/handler/EventSourceTransportHandler.java | 5 +++-- 9 files changed, 22 insertions(+), 15 deletions(-) diff --git a/framework-docs/modules/ROOT/pages/web/webmvc-functional.adoc b/framework-docs/modules/ROOT/pages/web/webmvc-functional.adoc index d68a19b2a4ce..354075203a92 100644 --- a/framework-docs/modules/ROOT/pages/web/webmvc-functional.adoc +++ b/framework-docs/modules/ROOT/pages/web/webmvc-functional.adoc @@ -276,7 +276,7 @@ ServerResponse.async(asyncResponse); ---- ====== -https://www.w3.org/TR/eventsource/[Server-Sent Events] can be provided via the +https://html.spec.whatwg.org/multipage/server-sent-events.html[Server-Sent Events] can be provided via the static `sse` method on `ServerResponse`. The builder provided by that method allows you to send Strings, or other objects as JSON. For example: diff --git a/framework-docs/modules/ROOT/pages/web/webmvc/mvc-ann-async.adoc b/framework-docs/modules/ROOT/pages/web/webmvc/mvc-ann-async.adoc index 9e248d5f24ce..7c67abdfcf7a 100644 --- a/framework-docs/modules/ROOT/pages/web/webmvc/mvc-ann-async.adoc +++ b/framework-docs/modules/ROOT/pages/web/webmvc/mvc-ann-async.adoc @@ -281,7 +281,7 @@ invokes the configured exception resolvers and completes the request. === SSE `SseEmitter` (a subclass of `ResponseBodyEmitter`) provides support for -https://www.w3.org/TR/eventsource/[Server-Sent Events], where events sent from the server +https://html.spec.whatwg.org/multipage/server-sent-events.html[Server-Sent Events], where events sent from the server are formatted according to the W3C SSE specification. To produce an SSE stream from a controller, return `SseEmitter`, as the following example shows: diff --git a/spring-web/src/main/java/org/springframework/http/MediaType.java b/spring-web/src/main/java/org/springframework/http/MediaType.java index 80a545073ac2..6ff35fd775be 100644 --- a/spring-web/src/main/java/org/springframework/http/MediaType.java +++ b/spring-web/src/main/java/org/springframework/http/MediaType.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -49,6 +49,7 @@ * @author Kazuki Shimizu * @author Sam Brannen * @author Hyoungjune Kim + * @author Taeik Lim * @since 3.0 * @see * HTTP 1.1: Semantics and Content, section 3.1.1.1 @@ -308,7 +309,7 @@ public class MediaType extends MimeType implements Serializable { /** * Media type for {@code text/event-stream}. * @since 4.3.6 - * @see Server-Sent Events W3C recommendation + * @see Server-Sent Events */ public static final MediaType TEXT_EVENT_STREAM; diff --git a/spring-web/src/main/java/org/springframework/http/codec/ServerSentEvent.java b/spring-web/src/main/java/org/springframework/http/codec/ServerSentEvent.java index e84a8571fd97..1ea5e588473f 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/ServerSentEvent.java +++ b/spring-web/src/main/java/org/springframework/http/codec/ServerSentEvent.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,10 +30,11 @@ * * @author Sebastien Deleuze * @author Arjen Poutsma + * @author Taeik Lim * @since 5.0 * @param the type of data that this event contains * @see ServerSentEventHttpMessageWriter - * @see Server-Sent Events W3C recommendation + * @see Server-Sent Events */ public final class ServerSentEvent { diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/BodyInserters.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/BodyInserters.java index c488e4979820..5b2dfa37a94e 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/BodyInserters.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/BodyInserters.java @@ -51,6 +51,7 @@ * @author Arjen Poutsma * @author Rossen Stoyanchev * @author Sebastien Deleuze + * @author Taeik Lim * @since 5.0 */ public abstract class BodyInserters { @@ -241,7 +242,7 @@ public static BodyInserter fr * @param eventsPublisher the {@code ServerSentEvent} publisher to write to the response body * @param the type of the data elements in the {@link ServerSentEvent} * @return the inserter to write a {@code ServerSentEvent} publisher - * @see Server-Sent Events W3C recommendation + * @see Server-Sent Events */ // Parameterized for server-side use public static >> BodyInserter fromServerSentEvents( diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/function/ServerResponse.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/function/ServerResponse.java index 8161462e818e..01fc63359769 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/function/ServerResponse.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/function/ServerResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -55,6 +55,7 @@ * {@linkplain HandlerFilterFunction filter function}. * * @author Arjen Poutsma + * @author Taeik Lim * @since 5.2 */ public interface ServerResponse { @@ -284,7 +285,7 @@ static ServerResponse async(Object asyncResponse, Duration timeout) { * @param consumer consumer that will be provided with an event builder * @return the server-side event response * @since 5.3.2 - * @see Server-Sent Events + * @see Server-Sent Events */ static ServerResponse sse(Consumer consumer) { return SseServerResponse.create(consumer, null); @@ -314,7 +315,7 @@ static ServerResponse sse(Consumer consumer) { * @param timeout maximum time period to wait before timing out * @return the server-side event response * @since 5.3.2 - * @see Server-Sent Events + * @see Server-Sent Events */ static ServerResponse sse(Consumer consumer, Duration timeout) { return SseServerResponse.create(consumer, timeout); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/function/SseServerResponse.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/function/SseServerResponse.java index acba901ba522..293de16f5d74 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/function/SseServerResponse.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/function/SseServerResponse.java @@ -46,10 +46,11 @@ /** * Implementation of {@link ServerResponse} for sending - * Server-Sent Events. + * Server-Sent Events. * * @author Arjen Poutsma * @author Sebastien Deleuze + * @author Taeik Lim * @since 5.3.2 */ final class SseServerResponse extends AbstractServerResponse { diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/SseEmitter.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/SseEmitter.java index 29ae344e57d8..f2c0ef1e7d0f 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/SseEmitter.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/SseEmitter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,12 +35,13 @@ /** * A specialization of {@link ResponseBodyEmitter} for sending - * Server-Sent Events. + * Server-Sent Events. * * @author Rossen Stoyanchev * @author Juergen Hoeller * @author Sam Brannen * @author Brian Clozel + * @author Taeik Lim * @since 4.2 */ public class SseEmitter extends ResponseBodyEmitter { diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/EventSourceTransportHandler.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/EventSourceTransportHandler.java index 90b56c378c5c..3441f0b857b6 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/EventSourceTransportHandler.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/EventSourceTransportHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,9 +31,10 @@ /** * A TransportHandler for sending messages via Server-Sent Events: - * https://dev.w3.org/html5/eventsource/. + * Server-Sent Events. * * @author Rossen Stoyanchev + * @author Taeik Lim * @since 4.0 */ public class EventSourceTransportHandler extends AbstractHttpSendingTransportHandler {