From 676ed2aa67b5c70ed3ed4338663dbb4076a09e6b Mon Sep 17 00:00:00 2001 From: Sdogruyol Date: Tue, 19 Jul 2016 21:01:49 +0300 Subject: [PATCH] Use send_file in built-in image handler --- src/kemal.cr | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/kemal.cr b/src/kemal.cr index a57580c..1444b1a 100644 --- a/src/kemal.cr +++ b/src/kemal.cr @@ -35,11 +35,7 @@ module Kemal image = env.params.url["image"] file_path = File.expand_path("libs/kemal/images/#{image}", Dir.current) if File.exists? file_path - env.response.headers.add "Content-Type", "application/octet-stream" - env.response.content_length = File.size(file_path) - File.open(file_path) do |file| - IO.copy(file, env.response) - end + send_file env, file_path end end