From db3a8a109e35958a35210eaa359278c4374c76dd Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Tue, 11 Jun 2024 00:36:28 +0300 Subject: Add header for nginx to disable buffering on SSE endpoint --- src/main/java/com/juick/www/api/Service.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/main/java/com/juick/www') diff --git a/src/main/java/com/juick/www/api/Service.java b/src/main/java/com/juick/www/api/Service.java index 310f1285..ed6699d2 100644 --- a/src/main/java/com/juick/www/api/Service.java +++ b/src/main/java/com/juick/www/api/Service.java @@ -37,6 +37,7 @@ import jakarta.mail.internet.AddressException; import jakarta.mail.internet.InternetAddress; import jakarta.mail.internet.MimeMessage; +import jakarta.servlet.http.HttpServletResponse; import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.RandomStringUtils; @@ -221,7 +222,8 @@ public class Service { } @GetMapping("/api/events") - public SseEmitter handle(@Parameter(hidden = true) User visitor) { + public SseEmitter handle(@Parameter(hidden = true) User visitor, HttpServletResponse response) { + response.addHeader("X-Accel-Buffering", "no"); logger.info("{} connected", visitor.getName()); if (!visitor.isAnonymous()) { userService.updateLastSeen(visitor); -- cgit v1.2.3