Skip to content

Commit

Permalink
Use rack constants for headers (#147)
Browse files Browse the repository at this point in the history
  • Loading branch information
brenogazzola authored Sep 27, 2023
1 parent 525baf2 commit 18979c1
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions lib/propshaft/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ def call(env)
if (asset = @assembly.load_path.find(path)) && asset.fresh?(digest)
compiled_content = @assembly.compilers.compile(asset)

[
200,
[
200,
{
"content-length" => compiled_content.length.to_s,
"content-type" => asset.content_type.to_s,
"vary" => "Accept-Encoding",
"etag" => asset.digest,
"cache-control" => "public, max-age=31536000, immutable"
Rack::CONTENT_LENGTH => compiled_content.length.to_s,
Rack::CONTENT_TYPE => asset.content_type.to_s,
VARY => "Accept-Encoding",
Rack::ETAG => asset.digest,
Rack::CACHE_CONTROL => "public, max-age=31536000, immutable"
},
[ compiled_content ]
]
else
[ 404, { "content-type" => "text/plain", "content-length" => "9" }, [ "Not found" ] ]
[ 404, { Rack::CONTENT_TYPE => "text/plain", Rack::CONTENT_LENGTH => "9" }, [ "Not found" ] ]
end
end

Expand All @@ -39,4 +39,10 @@ def extract_path_and_digest(env)

[ path, digest ]
end

if Gem::Version.new(Rack::RELEASE) < Gem::Version.new("3")
VARY = "Vary"
else
VARY = "vary"
end
end

0 comments on commit 18979c1

Please sign in to comment.