lib/grape/request.rb in grape-2.0.0 vs lib/grape/request.rb in grape-2.1.0
- old
+ new
@@ -1,9 +1,7 @@
# frozen_string_literal: true
-require 'grape/util/lazy_object'
-
module Grape
class Request < Rack::Request
HTTP_PREFIX = 'HTTP_'
alias rack_params params
@@ -34,26 +32,20 @@
args.delete(:route_info)
args
end
def build_headers
- Grape::Util::LazyObject.new do
- env.each_pair.with_object({}) do |(k, v), headers|
+ Grape::Util::Lazy::Object.new do
+ env.each_pair.with_object(Grape::Util::Header.new) do |(k, v), headers|
next unless k.to_s.start_with? HTTP_PREFIX
transformed_header = Grape::Http::Headers::HTTP_HEADERS[k] || transform_header(k)
headers[transformed_header] = v
end
end
end
- if Grape.lowercase_headers?
- def transform_header(header)
- -header[5..].tr('_', '-').downcase
- end
- else
- def transform_header(header)
- -header[5..].split('_').map(&:capitalize).join('-')
- end
+ def transform_header(header)
+ -header[5..].tr('_', '-').downcase
end
end
end