|
@ -35,6 +35,7 @@ const chunkExpression = common.chunkExpression; |
|
|
const httpSocketSetup = common.httpSocketSetup; |
|
|
const httpSocketSetup = common.httpSocketSetup; |
|
|
const OutgoingMessage = require('_http_outgoing').OutgoingMessage; |
|
|
const OutgoingMessage = require('_http_outgoing').OutgoingMessage; |
|
|
const { outHeadersKey, ondrain } = require('internal/http'); |
|
|
const { outHeadersKey, ondrain } = require('internal/http'); |
|
|
|
|
|
const errors = require('internal/errors'); |
|
|
|
|
|
|
|
|
const STATUS_CODES = { |
|
|
const STATUS_CODES = { |
|
|
100: 'Continue', |
|
|
100: 'Continue', |
|
@ -185,7 +186,9 @@ function writeHead(statusCode, reason, obj) { |
|
|
|
|
|
|
|
|
statusCode |= 0; |
|
|
statusCode |= 0; |
|
|
if (statusCode < 100 || statusCode > 999) |
|
|
if (statusCode < 100 || statusCode > 999) |
|
|
throw new RangeError(`Invalid status code: ${originalStatusCode}`); |
|
|
throw new errors.RangeError('ERR_HTTP_INVALID_STATUS_CODE', |
|
|
|
|
|
originalStatusCode); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (typeof reason === 'string') { |
|
|
if (typeof reason === 'string') { |
|
|
// writeHead(statusCode, reasonPhrase[, headers])
|
|
|
// writeHead(statusCode, reasonPhrase[, headers])
|
|
@ -211,8 +214,7 @@ function writeHead(statusCode, reason, obj) { |
|
|
} |
|
|
} |
|
|
if (k === undefined) { |
|
|
if (k === undefined) { |
|
|
if (this._header) { |
|
|
if (this._header) { |
|
|
throw new Error('Can\'t render headers after they are sent to the ' + |
|
|
throw new errors.Error('ERR_HTTP_HEADERS_SENT'); |
|
|
'client'); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
// only progressive api is used
|
|
|
// only progressive api is used
|
|
@ -223,7 +225,8 @@ function writeHead(statusCode, reason, obj) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (common._checkInvalidHeaderChar(this.statusMessage)) |
|
|
if (common._checkInvalidHeaderChar(this.statusMessage)) |
|
|
throw new Error('Invalid character in statusMessage.'); |
|
|
throw new errors.Error('ERR_HTTP_INVALID_CHAR', |
|
|
|
|
|
'Invalid character in statusMessage.'); |
|
|
|
|
|
|
|
|
var statusLine = 'HTTP/1.1 ' + statusCode + ' ' + this.statusMessage + CRLF; |
|
|
var statusLine = 'HTTP/1.1 ' + statusCode + ' ' + this.statusMessage + CRLF; |
|
|
|
|
|
|
|
|