summaryrefslogtreecommitdiff
path: root/lib/_http_outgoing.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/_http_outgoing.js')
-rw-r--r--lib/_http_outgoing.js14
1 files changed, 4 insertions, 10 deletions
diff --git a/lib/_http_outgoing.js b/lib/_http_outgoing.js
index d150a9d93c..7fe4e2133b 100644
--- a/lib/_http_outgoing.js
+++ b/lib/_http_outgoing.js
@@ -45,6 +45,7 @@ const {
ERR_STREAM_CANNOT_PIPE,
ERR_STREAM_WRITE_AFTER_END
} = require('internal/errors').codes;
+const { validateString } = require('internal/validators');
const { CRLF, debug } = common;
@@ -480,9 +481,7 @@ OutgoingMessage.prototype.setHeader = function setHeader(name, value) {
OutgoingMessage.prototype.getHeader = function getHeader(name) {
- if (typeof name !== 'string') {
- throw new ERR_INVALID_ARG_TYPE('name', 'string', name);
- }
+ validateString(name, 'name');
const headers = this[outHeadersKey];
if (headers === null)
@@ -516,19 +515,14 @@ OutgoingMessage.prototype.getHeaders = function getHeaders() {
OutgoingMessage.prototype.hasHeader = function hasHeader(name) {
- if (typeof name !== 'string') {
- throw new ERR_INVALID_ARG_TYPE('name', 'string', name);
- }
-
+ validateString(name, 'name');
return this[outHeadersKey] !== null &&
!!this[outHeadersKey][name.toLowerCase()];
};
OutgoingMessage.prototype.removeHeader = function removeHeader(name) {
- if (typeof name !== 'string') {
- throw new ERR_INVALID_ARG_TYPE('name', 'string', name);
- }
+ validateString(name, 'name');
if (this._header) {
throw new ERR_HTTP_HEADERS_SENT('remove');