Lahat ng language at framework
Vert.x Web Java
Isang Java snippet para sa Vert.x Web na sumasagot sa mga request sa /pixel.gif gamit ang empty GIF, na isang beses lang dine-decode sa startup.
Vert.x Web Java
import io.vertx.core.Vertx;
import io.vertx.core.buffer.Buffer;
import io.vertx.ext.web.Router;
import java.util.Base64;
public class Pixel {
private static final Buffer GIF = Buffer.buffer(Base64.getDecoder().decode("R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=="));
public static void main(String[] args) {
Vertx vertx = Vertx.vertx();
Router router = Router.router(vertx);
router.get("/pixel.gif").handler(ctx -> ctx.response()
.putHeader("Content-Type", "image/gif")
.putHeader("Cache-Control", "no-store")
.end(GIF));
vertx.createHttpServer().requestHandler(router).listen(8080);
}
}
Pinatakbo namin ang snippet na ito at ikinumpara ang mga byte na ibinalik nito.
Suriin
curl -sI http://localhost:8080/pixel.gif