HTTP.jl Julia
一个用于 HTTP.jl 的 Julia 代码片段,以空 GIF 响应对 /pixel.gif 的请求,GIF 在启动时只解码一次。
HTTP.jl Julia
using Base64
using HTTP
const GIF = base64decode("R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==")
const HEADERS = ["Content-Type" => "image/gif", "Cache-Control" => "no-store"]
router = HTTP.Router()
HTTP.register!(router, "GET", "/pixel.gif", _ -> HTTP.Response(200, HEADERS, GIF))
HTTP.serve(router, "0.0.0.0", 8080)
我们运行了此代码片段,并比对了它返回的字节。
验证
curl -sI http://localhost:8080/pixel.gif