MCPcopy Index your code
hub / github.com/Effect-TS/effect / ServerRequestImpl

Class ServerRequestImpl

packages/platform-node/src/internal/httpServer.ts:211–319  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

209}
210
211class ServerRequestImpl extends HttpIncomingMessageImpl<Error.RequestError> implements ServerRequest.HttpServerRequest {
212 readonly [ServerRequest.TypeId]: ServerRequest.TypeId
213
214 constructor(
215 readonly source: Http.IncomingMessage,
216 readonly response: Http.ServerResponse | LazyArg<Http.ServerResponse>,
217 private upgradeEffect?: Effect.Effect<Socket.Socket, Error.RequestError>,
218 readonly url = source.url!,
219 private headersOverride?: Headers.Headers,
220 remoteAddressOverride?: string
221 ) {
222 super(source, (cause) =>
223 new Error.RequestError({
224 request: this,
225 reason: "Decode",
226 cause
227 }), remoteAddressOverride)
228 this[ServerRequest.TypeId] = ServerRequest.TypeId
229 }
230
231 private cachedCookies: ReadonlyRecord<string, string> | undefined
232 get cookies() {
233 if (this.cachedCookies) {
234 return this.cachedCookies
235 }
236 return this.cachedCookies = Cookies.parseHeader(this.headers.cookie ?? "")
237 }
238
239 get resolvedResponse(): Http.ServerResponse {
240 return typeof this.response === "function" ? this.response() : this.response
241 }
242
243 modify(
244 options: {
245 readonly url?: string | undefined
246 readonly headers?: Headers.Headers | undefined
247 readonly remoteAddress?: string | undefined
248 }
249 ) {
250 return new ServerRequestImpl(
251 this.source,
252 this.response,
253 this.upgradeEffect,
254 options.url ?? this.url,
255 options.headers ?? this.headersOverride,
256 options.remoteAddress ?? this.remoteAddressOverride
257 )
258 }
259
260 get originalUrl(): string {
261 return this.source.url!
262 }
263
264 get method(): HttpMethod {
265 return this.source.method!.toUpperCase() as HttpMethod
266 }
267
268 get headers(): Headers.Headers {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected