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

Method onPollRequest

packages/engine.io/lib/transports-uws/polling.ts:71–106  ·  view source on GitHub ↗

* The client sends a request awaiting for us to send data. * * @private

(req, res)

Source from the content-addressed store, hash-verified

69 * @private
70 */
71 onPollRequest(req, res) {
72 if (this.req) {
73 debug("request overlap");
74 // assert: this.res, '.req and .res should be (un)set together'
75 this.onError("overlap from client");
76 res.writeStatus("500 Internal Server Error");
77 res.end();
78 return;
79 }
80
81 debug("setting request");
82
83 this.req = req;
84 this.res = res;
85
86 const onClose = () => {
87 this.writable = false;
88 this.onError("poll connection closed prematurely");
89 };
90
91 const cleanup = () => {
92 this.req = this.res = null;
93 };
94
95 req.cleanup = cleanup;
96 res.onAborted(onClose);
97
98 this.writable = true;
99 this.emit("ready");
100
101 // if we're still writable but had a pending close, trigger an empty send
102 if (this.writable && this.shouldClose) {
103 debug("triggering empty send to append close packet");
104 this.send([{ type: "noop" }]);
105 }
106 }
107
108 /**
109 * The client sends a request with data.

Callers 1

onRequestMethod · 0.95

Calls 7

sendMethod · 0.95
debugFunction · 0.85
writeStatusMethod · 0.80
onAbortedMethod · 0.80
emitMethod · 0.65
onErrorMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected