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

Function fromWeb

packages/effect/src/unstable/http/HttpServerResponse.ts:1377–1401  ·  view source on GitHub ↗
(response: Response)

Source from the content-addressed store, hash-verified

1375 * @since 4.0.0
1376 */
1377export const fromWeb = (response: Response): HttpServerResponse => {
1378 const headers = new globalThis.Headers(response.headers)
1379 const setCookieHeaders = headers.getSetCookie()
1380 headers.delete("set-cookie")
1381 let self = empty({
1382 status: response.status,
1383 statusText: response.statusText,
1384 headers: headers as any,
1385 cookies: Cookies.fromSetCookie(setCookieHeaders)
1386 })
1387 if (response.body) {
1388 const contentType = response.headers.get("content-type")
1389 self = setBody(
1390 self,
1391 Body.stream(
1392 Stream.fromReadableStream({
1393 evaluate: () => response.body!,
1394 onError: (e) => e
1395 }),
1396 contentType ?? undefined
1397 )
1398 )
1399 }
1400 return self
1401}

Callers

nothing calls this directly

Calls 3

emptyFunction · 0.70
getMethod · 0.65
streamMethod · 0.65

Tested by

no test coverage detected