Skip to content

Commit d566150

Browse files
authored
Loosen type restrictions in StaticFileHandler helper methods from File to IO (#16238)
1 parent 20d44c0 commit d566150

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/http/server/handlers/static_file_handler.cr

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,8 @@ class HTTP::StaticFileHandler
159159
end
160160
end
161161

162-
private def serve_file_range(context : Server::Context, file : File, range_header : String, file_info)
162+
# *file* should be seekable, that's implement #seek method
163+
private def serve_file_range(context : Server::Context, file : IO, range_header : String, file_info)
163164
range_header = range_header.lchop?("bytes=")
164165
unless range_header
165166
context.response.headers["Content-Range"] = "bytes */#{file_info.size}"
@@ -217,7 +218,7 @@ class HTTP::StaticFileHandler
217218
end
218219
end
219220

220-
private def serve_file_full(context : Server::Context, file : File, file_info)
221+
private def serve_file_full(context : Server::Context, file : IO, file_info)
221222
context.response.status = :ok
222223
context.response.content_length = file_info.size
223224
IO.copy(file, context.response)

0 commit comments

Comments
 (0)