Early return from range if request type is not GET
This commit is contained in:
parent
0543142a10
commit
476b27892e
5 changed files with 37 additions and 40 deletions
|
@ -4,7 +4,6 @@ require "./kemal/*"
|
||||||
require "./kemal/helpers/*"
|
require "./kemal/helpers/*"
|
||||||
|
|
||||||
module Kemal
|
module Kemal
|
||||||
|
|
||||||
# Overload of self.run with the default startup logging
|
# Overload of self.run with the default startup logging
|
||||||
def self.run(port = nil)
|
def self.run(port = nil)
|
||||||
self.run port do
|
self.run port do
|
||||||
|
@ -17,7 +16,6 @@ module Kemal
|
||||||
self.run nil & block
|
self.run nil & block
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
# The command to run a `Kemal` application.
|
# The command to run a `Kemal` application.
|
||||||
# The port can be given to `#run` but is optional.
|
# The port can be given to `#run` but is optional.
|
||||||
# If not given Kemal will use `Kemal::Config#port`
|
# If not given Kemal will use `Kemal::Config#port`
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
class HTTP::Server::Response
|
class HTTP::Server::Response
|
||||||
class Output
|
class Output
|
||||||
def close
|
def close
|
||||||
|
|
||||||
unless response.wrote_headers? && !response.headers.has_key?("Content-Range")
|
unless response.wrote_headers? && !response.headers.has_key?("Content-Range")
|
||||||
response.content_length = @out_count
|
response.content_length = @out_count
|
||||||
end
|
end
|
||||||
|
|
|
@ -56,7 +56,7 @@ module Kemal
|
||||||
request_headers = context.request.headers
|
request_headers = context.request.headers
|
||||||
filesize = File.size(file_path)
|
filesize = File.size(file_path)
|
||||||
File.open(file_path) do |file|
|
File.open(file_path) do |file|
|
||||||
if context.request.headers.has_key?("Range") && context.request.method == "GET"
|
if context.request.method == "GET" && context.request.headers.has_key?("Range")
|
||||||
next multipart(file, context)
|
next multipart(file, context)
|
||||||
end
|
end
|
||||||
if request_headers.includes_word?("Accept-Encoding", "gzip") && config.is_a?(Hash) && config["gzip"] == true && filesize > minsize && Utils.zip_types(file_path)
|
if request_headers.includes_word?("Accept-Encoding", "gzip") && config.is_a?(Hash) && config["gzip"] == true && filesize > minsize && Utils.zip_types(file_path)
|
||||||
|
|
Loading…
Reference in a new issue