Plug + Bandit Elixir
Plug + Bandit ਲਈ Elixir ਸਨਿੱਪਟ, ਜੋ /pixel.gif ਦੀਆਂ ਬੇਨਤੀਆਂ ਦਾ ਜਵਾਬ ਖਾਲੀ GIF ਨਾਲ ਦਿੰਦਾ ਹੈ; GIF ਸ਼ੁਰੂਆਤ ’ਤੇ ਇੱਕ ਵਾਰ ਡੀਕੋਡ ਹੁੰਦੀ ਹੈ।
Plug + Bandit Elixir
Mix.install([:plug, :bandit])
defmodule Pixel.Router do
use Plug.Router
@gif Base.decode64!("R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==")
plug :match
plug :dispatch
get "/pixel.gif" do
conn
|> put_resp_content_type("image/gif", nil)
|> put_resp_header("cache-control", "no-store")
|> send_resp(200, @gif)
end
match _ do
send_resp(conn, 404, "Not Found")
end
end
Bandit.start_link(plug: Pixel.Router, port: 8080)
Process.sleep(:infinity)
ਅਸੀਂ ਇਹ ਸਨਿੱਪਟ ਚਲਾਇਆ ਅਤੇ ਇਸ ਵੱਲੋਂ ਵਾਪਸ ਕੀਤੀਆਂ ਬਾਈਟਾਂ ਦੀ ਤੁਲਨਾ ਕੀਤੀ।
ਜਾਂਚੋ
curl -sI http://localhost:8080/pixel.gif