Rack Ruby
Rack માટે Ruby સ્નિપેટ, જે /pixel.gif પરની રિક્વેસ્ટનો જવાબ empty GIF થી આપે છે. GIF સ્ટાર્ટઅપ વખતે એક જ વાર ડિકોડ થાય છે.
Rack Ruby
GIF = "R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==".unpack1("m0").freeze
HEADERS = {
"content-type" => "image/gif",
"content-length" => GIF.bytesize.to_s,
"cache-control" => "no-store",
}.freeze
run lambda { |env|
if env["REQUEST_METHOD"] == "GET" && env["PATH_INFO"] == "/pixel.gif"
[200, HEADERS.dup, [GIF]]
else
[404, { "content-type" => "text/plain" }, ["Not Found"]]
end
}
અમે આ સ્નિપેટ ચલાવ્યો અને તેણે પરત કરેલા બાઇટની સરખામણી કરી.
ચકાસો
curl -sI http://localhost:8080/pixel.gif