From 554d39807bbddeee003a795996b2556f078c5610 Mon Sep 17 00:00:00 2001 From: bopol Date: Fri, 5 Feb 2021 18:53:05 +0100 Subject: [PATCH] add status code to server response --- src/main/java/me/kavin/piped/Main.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/me/kavin/piped/Main.java b/src/main/java/me/kavin/piped/Main.java index a5cb610..a1e8563 100644 --- a/src/main/java/me/kavin/piped/Main.java +++ b/src/main/java/me/kavin/piped/Main.java @@ -227,13 +227,19 @@ public class Main { } public static NettyOutbound writeResponse(HttpServerResponse res, byte[] resp, int code, String cache, long time) { - return res.compression(true).addHeader(ACCESS_CONTROL_ALLOW_ORIGIN, "*").addHeader(CACHE_CONTROL, cache) + return res.compression(true) + .status(code) + .addHeader(ACCESS_CONTROL_ALLOW_ORIGIN, "*") + .addHeader(CACHE_CONTROL, cache) .addHeader("Server-Timing", "app;dur=" + (System.nanoTime() - time) / 1000000.0) .sendByteArray(Flux.just(resp)); } public static NettyOutbound writeResponse(HttpServerResponse res, Flux resp, int code, String cache) { - return res.compression(true).addHeader(ACCESS_CONTROL_ALLOW_ORIGIN, "*").addHeader(CACHE_CONTROL, cache) + return res.compression(true) + .status(code) + .addHeader(ACCESS_CONTROL_ALLOW_ORIGIN, "*") + .addHeader(CACHE_CONTROL, cache) .send(ByteBufFlux.fromString(resp, java.nio.charset.StandardCharsets.UTF_8, ByteBufAllocator.DEFAULT)); } }