Commit 8400ba3
committed
Fix warning with send_file.t on Windows:
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.1 parent 92892c2 commit 8400ba3
1 file changed
Lines changed: 2 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
10 | 9 | | |
11 | 10 | | |
12 | 11 | | |
| |||
45 | 44 | | |
46 | 45 | | |
47 | 46 | | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
| 47 | + | |
| 48 | + | |
53 | 49 | | |
54 | 50 | | |
55 | 51 | | |
| |||
0 commit comments