From 4fefd9cb5cbc2fa9058f4d338ebd501a72e70879 Mon Sep 17 00:00:00 2001 From: sdogruyol Date: Mon, 17 Dec 2018 18:58:02 +0300 Subject: [PATCH] WIP --- src/kemal/base.cr | 14 ++++++++++---- src/kemal/helpers/file_helpers.cr | 2 +- src/kemal/main.cr | 1 - 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/kemal/base.cr b/src/kemal/base.cr index e1451012..bbb073a5 100644 --- a/src/kemal/base.cr +++ b/src/kemal/base.cr @@ -80,12 +80,18 @@ class Kemal::Base end private def start_server(port) - @server = server = HTTP::Server.new(@config.host_binding, port || @config.port, @handlers) - {% if !flag?(:without_openssl) %} - server.tls = config.ssl + @server = server = HTTP::Server.new(@handlers) + + {% if flag?(:without_openssl) %} + server.bind_tcp(@config.host_binding, port || @config.port) + {% else %} + if ssl = config.ssl + server.bind_tls(@config.host_binding, port || @config.port, ssl) + else + server.bind_tcp(@config.host_binding, port || @config.port) + end {% end %} - server.bind @running = true yield diff --git a/src/kemal/helpers/file_helpers.cr b/src/kemal/helpers/file_helpers.cr index cdc2b65c..ade82880 100644 --- a/src/kemal/helpers/file_helpers.cr +++ b/src/kemal/helpers/file_helpers.cr @@ -22,7 +22,7 @@ module Kemal::FileHelpers minsize = 860 # http://webmasters.stackexchange.com/questions/31750/what-is-recommended-minimum-object-size-for-gzip-performance-benefits ?? request_headers = env.request.headers filesize = File.size(file_path) - filestat = File.stat(file_path) + filestat = File.info(file_path) config.static_headers.try(&.call(env.response, file_path, filestat)) gzip = config.serve_static?("gzip") diff --git a/src/kemal/main.cr b/src/kemal/main.cr index c0b3bcac..4a66d1a5 100644 --- a/src/kemal/main.cr +++ b/src/kemal/main.cr @@ -1,7 +1,6 @@ require "http" require "json" require "uri" -require "tempfile" require "./application" require "./base_log_handler" require "./cli"