test: unflake some net specs (#18782)
This commit is contained in:
parent
45f5f2ba1a
commit
7b26048d9e
3 changed files with 1304 additions and 1716 deletions
|
@ -96,11 +96,11 @@ class IncomingMessage extends Readable {
|
|||
}
|
||||
|
||||
get rawTrailers () {
|
||||
throw new Error('HTTP trailers are not supported.')
|
||||
throw new Error('HTTP trailers are not supported')
|
||||
}
|
||||
|
||||
get trailers () {
|
||||
throw new Error('HTTP trailers are not supported.')
|
||||
throw new Error('HTTP trailers are not supported')
|
||||
}
|
||||
|
||||
_storeInternalData (chunk) {
|
||||
|
@ -161,7 +161,7 @@ class ClientRequest extends EventEmitter {
|
|||
const urlObj = {}
|
||||
const protocol = options.protocol || 'http:'
|
||||
if (!kSupportedProtocols.has(protocol)) {
|
||||
throw new Error('Protocol "' + protocol + '" not supported. ')
|
||||
throw new Error('Protocol "' + protocol + '" not supported')
|
||||
}
|
||||
urlObj.protocol = protocol
|
||||
|
||||
|
@ -186,7 +186,7 @@ class ClientRequest extends EventEmitter {
|
|||
// well, and b) possibly too restrictive for real-world usage. That's
|
||||
// why it only scans for spaces because those are guaranteed to create
|
||||
// an invalid request.
|
||||
throw new TypeError('Request path contains unescaped characters.')
|
||||
throw new TypeError('Request path contains unescaped characters')
|
||||
}
|
||||
const pathObj = url.parse(options.path || '/')
|
||||
urlObj.pathname = pathObj.pathname
|
||||
|
@ -209,13 +209,13 @@ class ClientRequest extends EventEmitter {
|
|||
if (options.session instanceof Session) {
|
||||
urlRequestOptions.session = options.session
|
||||
} else {
|
||||
throw new TypeError('`session` should be an instance of the Session class.')
|
||||
throw new TypeError('`session` should be an instance of the Session class')
|
||||
}
|
||||
} else if (options.partition) {
|
||||
if (typeof options.partition === 'string') {
|
||||
urlRequestOptions.partition = options.partition
|
||||
} else {
|
||||
throw new TypeError('`partition` should be an a string.')
|
||||
throw new TypeError('`partition` should be a string')
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -276,20 +276,20 @@ class ClientRequest extends EventEmitter {
|
|||
|
||||
set chunkedEncoding (value) {
|
||||
if (!this.urlRequest.notStarted) {
|
||||
throw new Error('Can\'t set the transfer encoding, headers have been sent.')
|
||||
throw new Error('Can\'t set the transfer encoding, headers have been sent')
|
||||
}
|
||||
this.chunkedEncodingEnabled = value
|
||||
}
|
||||
|
||||
setHeader (name, value) {
|
||||
if (typeof name !== 'string') {
|
||||
throw new TypeError('`name` should be a string in setHeader(name, value).')
|
||||
throw new TypeError('`name` should be a string in setHeader(name, value)')
|
||||
}
|
||||
if (value == null) {
|
||||
throw new Error('`value` required in setHeader("' + name + '", value).')
|
||||
throw new Error('`value` required in setHeader("' + name + '", value)')
|
||||
}
|
||||
if (!this.urlRequest.notStarted) {
|
||||
throw new Error('Can\'t set headers after they are sent.')
|
||||
throw new Error('Can\'t set headers after they are sent')
|
||||
}
|
||||
|
||||
const key = name.toLowerCase()
|
||||
|
@ -299,7 +299,7 @@ class ClientRequest extends EventEmitter {
|
|||
|
||||
getHeader (name) {
|
||||
if (name == null) {
|
||||
throw new Error('`name` is required for getHeader(name).')
|
||||
throw new Error('`name` is required for getHeader(name)')
|
||||
}
|
||||
|
||||
if (!this.extraHeaders) {
|
||||
|
@ -312,11 +312,11 @@ class ClientRequest extends EventEmitter {
|
|||
|
||||
removeHeader (name) {
|
||||
if (name == null) {
|
||||
throw new Error('`name` is required for removeHeader(name).')
|
||||
throw new Error('`name` is required for removeHeader(name)')
|
||||
}
|
||||
|
||||
if (!this.urlRequest.notStarted) {
|
||||
throw new Error('Can\'t remove headers after they are sent.')
|
||||
throw new Error('Can\'t remove headers after they are sent')
|
||||
}
|
||||
|
||||
const key = name.toLowerCase()
|
||||
|
@ -328,7 +328,7 @@ class ClientRequest extends EventEmitter {
|
|||
const chunkIsString = typeof chunk === 'string'
|
||||
const chunkIsBuffer = chunk instanceof Buffer
|
||||
if (!chunkIsString && !chunkIsBuffer) {
|
||||
throw new TypeError('First argument must be a string or Buffer.')
|
||||
throw new TypeError('First argument must be a string or Buffer')
|
||||
}
|
||||
|
||||
if (chunkIsString) {
|
||||
|
@ -357,7 +357,7 @@ class ClientRequest extends EventEmitter {
|
|||
|
||||
write (data, encoding, callback) {
|
||||
if (this.urlRequest.finished) {
|
||||
const error = new Error('Write after end.')
|
||||
const error = new Error('Write after end')
|
||||
process.nextTick(writeAfterEndNT, this, error, callback)
|
||||
return true
|
||||
}
|
||||
|
|
1289
spec-main/api-net-spec.ts
Normal file
1289
spec-main/api-net-spec.ts
Normal file
File diff suppressed because it is too large
Load diff
1701
spec/api-net-spec.js
1701
spec/api-net-spec.js
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue