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

Function fromWebBody

packages/effect/src/http/HttpClientRequest.ts:1156–1164  ·  view source on GitHub ↗
(request: globalThis.Request, method: string)

Source from the content-addressed store, hash-verified

1154}
1155
1156const fromWebBody = (request: globalThis.Request, method: string): HttpBody.HttpBody => {
1157 if (!hasBody(method) || request.body === null) {
1158 return HttpBody.empty
1159 }
1160 return HttpBody.raw(request.body, {
1161 contentType: request.headers.get("content-type") ?? undefined,
1162 contentLength: bodyInternal.parseContentLength(request.headers.get("content-length"))
1163 })
1164}
1165
1166/**
1167 * Converts an `HttpClientRequest` safely to a Web `Request` as a `Result`, failing when the request URL is invalid.

Callers 1

fromWebFunction · 0.85

Calls 3

hasBodyFunction · 0.90
getMethod · 0.65
rawMethod · 0.45

Tested by

no test coverage detected