Skip to content

Conversation

@kitlangton
Copy link
Contributor

Summary

  • Fix HttpServerResponse.fromWeb to preserve the Content-Type header when converting a web Response to HttpServerResponse
  • Previously, when the response had a body, the Content-Type was not passed to Body.stream(), causing it to default to application/octet-stream
  • This affected any code using HttpApp.fromWebHandler to wrap web handlers (e.g., integrating third-party auth libraries like Better Auth)

Test Plan

  • Added test preserves response content-type header - verifies JSON responses have correct content-type
  • Added test preserves custom content-type header - verifies custom content-types like text/html are preserved
  • Added test json preserves content-type - verifies toWebHandler correctly outputs content-type

All 175 tests pass.

Example

Before this fix, wrapping a web handler would lose the Content-Type:

const webHandler = async () => Response.json({ message: "hello" })
const app = HttpApp.fromWebHandler(webHandler)
const handler = HttpApp.toWebHandler(app)
const response = await handler(new Request("http://localhost/"))

// Before: response.headers.get("Content-Type") === "application/octet-stream" ❌
// After:  response.headers.get("Content-Type") === "application/json" ✅

When converting a web Response to HttpServerResponse via fromWeb,
the Content-Type header was not being passed to Body.stream(),
causing it to default to "application/octet-stream".

This affected any code using HttpApp.fromWebHandler to wrap web
handlers, as JSON responses would incorrectly have their
Content-Type set to "application/octet-stream" instead of
"application/json".

Added tests to verify Content-Type preservation in both toWebHandler
and fromWebHandler round-trips.
@github-project-automation github-project-automation bot moved this to Discussion Ongoing in PR Backlog Dec 31, 2025
@changeset-bot
Copy link

changeset-bot bot commented Dec 31, 2025

🦋 Changeset detected

Latest commit: 1e1cac7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 31 packages
Name Type
@effect/platform Patch
@effect/cli Patch
@effect/cluster Patch
@effect/experimental Patch
@effect/opentelemetry Patch
@effect/platform-browser Patch
@effect/platform-bun Patch
@effect/platform-node-shared Patch
@effect/platform-node Patch
@effect/rpc Patch
@effect/sql-clickhouse Patch
@effect/sql-d1 Patch
@effect/sql-drizzle Patch
@effect/sql-libsql Patch
@effect/sql-mssql Patch
@effect/sql-mysql2 Patch
@effect/sql-pg Patch
@effect/sql-sqlite-bun Patch
@effect/sql-sqlite-node Patch
@effect/sql Patch
@effect/workflow Patch
@effect/ai Patch
@effect/ai-amazon-bedrock Patch
@effect/ai-anthropic Patch
@effect/ai-google Patch
@effect/ai-openai Patch
@effect/ai-openrouter Patch
@effect/sql-sqlite-do Patch
@effect/sql-sqlite-react-native Patch
@effect/sql-sqlite-wasm Patch
@effect/sql-kysely Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@kitlangton
Copy link
Contributor Author

@tim-smart tim-smart merged commit ee69cd7 into main Dec 31, 2025
11 checks passed
@tim-smart tim-smart deleted the fix/http-server-response-from-web-content-type branch December 31, 2025 23:18
@github-project-automation github-project-automation bot moved this from Discussion Ongoing to Done in PR Backlog Dec 31, 2025
@github-actions github-actions bot mentioned this pull request Dec 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants