Skip to content

BunHttpPlatform: fileWeb ignores the file name when File.type is empty #10870

Open

Description

@devangpratap

On Bun, HttpServerResponse.fileWeb with a File that has an empty type is served as text/plain;charset=utf-8, whatever its name. Node, Deno and the default web platform look the type up from the file name (#8254), so the same handler serves data.json as application/json there.

import * as BunHttpPlatform from "@effect/platform-bun/BunHttpPlatform"
import { Effect } from "effect"
import * as HttpPlatform from "effect/http/HttpPlatform"

Effect.gen(function*() {
  const platform = yield* HttpPlatform.HttpPlatform
  const response = yield* platform.fileWebResponse(new File(["{}"], "data.json"))
  console.log(response.headers["content-type"]) // undefined, sent as text/plain;charset=utf-8
}).pipe(Effect.provide(BunHttpPlatform.layer), Effect.runPromise)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions