http_server.js (873:89f7d6b67fa7) http_server.js (874:5df32621af19)
1
2/*
3 * Copyright (C) NGINX, Inc.
4 */
5
6'use strict';
7
8const EventEmitter = require('events');

--- 203 unchanged lines hidden (view full) ---

212 } else {
213 contentLength = chunk.length;
214 }
215
216 unit_lib.unit_response_write(this, chunk, contentLength);
217 }
218
219 if (typeof callback === 'function') {
1
2/*
3 * Copyright (C) NGINX, Inc.
4 */
5
6'use strict';
7
8const EventEmitter = require('events');

--- 203 unchanged lines hidden (view full) ---

212 } else {
213 contentLength = chunk.length;
214 }
215
216 unit_lib.unit_response_write(this, chunk, contentLength);
217 }
218
219 if (typeof callback === 'function') {
220 callback(this);
220 /*
221 * The callback must be called only when response.write() caller
222 * completes. process.nextTick() postpones the callback execution.
223 *
224 * process.nextTick() is not technically part of the event loop.
225 * Instead, the nextTickQueue will be processed after the current
226 * operation completes, regardless of the current phase of
227 * the event loop. All callbacks passed to process.nextTick()
228 * will be resolved before the event loop continues.
229 */
230 process.nextTick(function () {
231 callback(this);
232 }.bind(this));
221 }
222};
223
224ServerResponse.prototype.write = function write(chunk, encoding, callback) {
225 if (this.finished) {
226 throw new Error("Write after end");
227 }
228

--- 144 unchanged lines hidden ---
233 }
234};
235
236ServerResponse.prototype.write = function write(chunk, encoding, callback) {
237 if (this.finished) {
238 throw new Error("Write after end");
239 }
240

--- 144 unchanged lines hidden ---