Skip to content

Commit

Permalink
fix(base): last modified check
Browse files Browse the repository at this point in the history
the HTTP header ignores milliseconds which means we need to reduce the accuracy of the comparisons for exact matches
  • Loading branch information
stakach committed Mar 12, 2024
1 parent a22c7ef commit 84be5bb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion shard.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: action-controller
version: 7.4.0
version: 7.4.1
crystal: ">= 1.9.0"

dependencies:
Expand Down
6 changes: 5 additions & 1 deletion src/action-controller/base.cr
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,11 @@ abstract class ActionController::Base
end

if last_modified
resp_headers["Last-Modified"] = HTTP.format_time(last_modified)
# we need to update this as the HTTP header is less exact
check_time = HTTP.format_time(last_modified)
resp_headers["Last-Modified"] = check_time
last_modified = HTTP.parse_time(check_time).as(Time)

if req_modified = req_headers["If-Modified-Since"]?
modified_since = HTTP.parse_time(req_modified)
end
Expand Down

0 comments on commit 84be5bb

Please sign in to comment.