Helidon SE Java
A Java snippet for Helidon SE that answers requests for /pixel.gif with the empty GIF, decoded once at startup.
Helidon SE Java
import io.helidon.http.HeaderNames;
import io.helidon.webserver.WebServer;
import java.util.Base64;
public class Pixel {
private static final byte[] GIF = Base64.getDecoder().decode("R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==");
public static void main(String[] args) {
WebServer.builder()
.port(8080)
.routing(routing -> routing.get("/pixel.gif", (req, res) -> {
res.header(HeaderNames.CONTENT_TYPE, "image/gif");
res.header(HeaderNames.CACHE_CONTROL, "no-store");
res.send(GIF);
}))
.build()
.start();
}
}
We ran this snippet and compared the bytes it returned.
Check it
curl -sI http://localhost:8080/pixel.gif