Skip to content

Commit

Permalink
specify buffering header for nginx users
Browse files Browse the repository at this point in the history
  • Loading branch information
granny committed Mar 9, 2024
1 parent 37004de commit 42a15d6
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions core/src/main/java/net/pl3x/map/core/httpd/HttpdServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import io.undertow.server.handlers.sse.ServerSentEventHandler;
import io.undertow.util.ETag;
import io.undertow.util.Headers;
import io.undertow.util.HttpString;
import io.undertow.util.StatusCodes;
import java.io.IOException;
import java.nio.file.Files;
Expand All @@ -51,6 +52,7 @@
import net.pl3x.map.core.world.World;

public class HttpdServer {
private HttpString X_ACCEL_BUFFERING = new HttpString("X-Accel-Buffering");
private Undertow server;
private ServerSentEventHandler serverSentEventHandler = Handlers.serverSentEvents();

Expand Down Expand Up @@ -131,6 +133,7 @@ public void startServer() {
.add("{world}", exchange -> {
String worldName = exchange.getQueryParameters().get("world").peek();
if (worldName == null || worldName.isEmpty()) {
exchange.getResponseHeaders().put(X_ACCEL_BUFFERING, "no");
serverSentEventHandler.handleRequest(exchange);
return;
}
Expand All @@ -149,6 +152,7 @@ public void startServer() {
if (exchange.isInIoThread()) {
exchange.dispatch(world.getServerSentEventHandler());
} else {
exchange.getResponseHeaders().put(X_ACCEL_BUFFERING, "no");
world.getServerSentEventHandler().handleRequest(exchange);
}
})
Expand Down

0 comments on commit 42a15d6

Please sign in to comment.