MCPcopy
hub / github.com/socketio/socket.io / prepare

Method prepare

packages/engine.io/lib/userver.ts:40–60  ·  view source on GitHub ↗

* Prepares a request by processing the query string. * * @private

(req: HttpRequest & EngineRequest, res: HttpResponse)

Source from the content-addressed store, hash-verified

38 * @private
39 */
40 private prepare(req: HttpRequest & EngineRequest, res: HttpResponse) {
41 req.method = req.getMethod().toUpperCase();
42 req.url = req.getUrl();
43
44 const params = new URLSearchParams(req.getQuery());
45 req._query = Object.fromEntries(params.entries());
46
47 req.headers = {};
48 req.forEach((key, value) => {
49 req.headers[key] = value;
50 });
51
52 // @ts-expect-error
53 req.connection = {
54 remoteAddress: Buffer.from(res.getRemoteAddressAsText()).toString(),
55 };
56
57 res.onAborted(() => {
58 debug("response has been aborted");
59 });
60 }
61
62 protected createTransport(transportName: string, req: EngineRequest) {
63 return new transports[transportName](req);

Callers 2

handleRequestMethod · 0.95
handleUpgradeMethod · 0.95

Calls 2

debugFunction · 0.85
onAbortedMethod · 0.80

Tested by

no test coverage detected