MCPcopy Create free account
hub / github.com/Effect-TS/effect / fileResponse

Function fileResponse

packages/platform/node/src/NodeHttpPlatform.ts:79–92  ·  view source on GitHub ↗
(path, status, statusText, headers, start, end, contentLength)

Source from the content-addressed store, hash-verified

77 platform: "node",
78 compression,
79 fileResponse(path, status, statusText, headers, start, end, contentLength) {
80 const stream = contentLength === 0
81 ? Readable.from([])
82 : Fs.createReadStream(path, { start, end: end === undefined ? undefined : end - 1 })
83 return ServerResponse.raw(stream, {
84 headers: {
85 ...headers,
86 "content-type": headers["content-type"] ?? Mime.getType(path) ?? "application/octet-stream",
87 "content-length": contentLength.toString()
88 },
89 status,
90 statusText
91 })
92 },
93 fileWebResponse(file, status, statusText, headers, _options) {
94 return ServerResponse.raw(Readable.fromWeb(file.stream() as any), {
95 headers: Headers.merge(

Callers

nothing calls this directly

Calls 2

rawMethod · 0.80
toStringMethod · 0.65

Tested by

no test coverage detected