அனைத்து மொழிகளும் ஃப்ரேம்வொர்க்குகளும்
Crystal standard library (HTTP::Server) Crystal
/pixel.gif க்கு வரும் ரெக்வெஸ்ட்களுக்கு empty GIF மூலம் பதிலளிக்கும், Crystal standard library (HTTP::Server) க்கான Crystal ஸ்னிப்பெட். GIF ஸ்டார்ட்அப்பில் ஒருமுறை மட்டுமே டீகோட் செய்யப்படுகிறது.
Crystal standard library (HTTP::Server) Crystal
require "base64"
require "http/server"
GIF = Base64.decode("R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==")
server = HTTP::Server.new do |context|
request, response = context.request, context.response
if request.method == "GET" && request.path == "/pixel.gif"
response.content_type = "image/gif"
response.headers["Cache-Control"] = "no-store"
response.content_length = GIF.size
response.write(GIF)
else
response.respond_with_status(:not_found)
end
end
server.bind_tcp "0.0.0.0", 8080
server.listen
ஃப்ரேம்வொர்க்கின் தற்போதைய டாக்குமென்டேஷனுடன் ஒப்பிட்டுச் சரிபார்க்கப்பட்டது.
சரிபார்
curl -sI http://localhost:8080/pixel.gif
அதிகாரப்பூர்வ சைட்: Crystal standard library (HTTP::Server)