Skip to content

Commit

Permalink
Fetch http client merge headers (#4493)
Browse files Browse the repository at this point in the history
Co-authored-by: Tim <[email protected]>
  • Loading branch information
leonitousconforti and tim-smart authored Mar 3, 2025
1 parent a95108a commit 0d01480
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/twelve-badgers-turn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@effect/platform": patch
---

FetchHttpClient merge headers from request and requestInit
3 changes: 2 additions & 1 deletion packages/platform/src/internal/fetchHttpClient.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as Effect from "effect/Effect"
import * as FiberRef from "effect/FiberRef"
import * as Stream from "effect/Stream"
import * as Headers from "../Headers.js"
import type * as Client from "../HttpClient.js"
import * as Error from "../HttpClientError.js"
import * as client from "./httpClient.js"
Expand All @@ -15,7 +16,7 @@ const fetch: Client.HttpClient = client.make((request, url, signal, fiber) => {
const context = fiber.getFiberRef(FiberRef.currentContext)
const fetch: typeof globalThis.fetch = context.unsafeMap.get(fetchTagKey) ?? globalThis.fetch
const options: RequestInit = context.unsafeMap.get(requestInitTagKey) ?? {}
const headers = new globalThis.Headers(request.headers)
const headers = options.headers ? Headers.merge(Headers.fromInput(options.headers), request.headers) : request.headers
const send = (body: BodyInit | undefined) =>
Effect.map(
Effect.tryPromise({
Expand Down

0 comments on commit 0d01480

Please sign in to comment.