Merged
Conversation
File::Temp on Windows uses `FILE_FLAG_DELETE_ON_CLOSE` semantics. The temp file is deleted when the OS file handle is closed. So `close $temp` deletes the file, and `send_file($temp->filename, ...)` subsequently fails the `$file_path->exists` check, which calls `$err_response->(403)`, setting content type to `text/plain` and returning a 403. So instead, we replace the File::Temp usage in the `check_content_type` route with `Path::Tiny::path(__FILE__)->absolute->stringify`, which is the same pattern the `/no_streaming` and `/options_streaming` routes already use. The test only needs a readable file to verify that `content_type => 'image/png'` overrides MIME auto-detection. It doesn't require a temp file. The core `send_file` implementation handles Windows absolute paths correctly (via the fix in df6a0a4). The issue was purely with the test's temp-file lifecycle assumption.
Contributor
|
that looks clever, and tests indeed indicate it passes quietly now :) |
Member
Author
|
Confirmation from @wchristian is all I need to merge. :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Confusing as heck... Closes GH #1772.
File::Temp on Windows uses
FILE_FLAG_DELETE_ON_CLOSEsemantics. The temp file is deleted when the OS file handle is closed. Soclose $tempdeletes the file, andsend_file($temp->filename, ...)subsequently fails the$file_path->existscheck, which calls$err_response->(403), setting content type totext/plainand returning a 403.So instead, we replace the File::Temp usage in the
check_content_typeroute withPath::Tiny::path(__FILE__)->absolute->stringify, which is the same pattern the/no_streamingand/options_streamingroutes already use. The test only needs a readable file to verify thatcontent_type => 'image/png'overrides MIME auto-detection. It doesn't require a temp file.The core
send_fileimplementation handles Windows absolute paths correctly (via the fix in df6a0a4). The issue was purely with the test's temp-file lifecycle assumption.@wchristian now it's in your hands to confirm. :)