-
-
Notifications
You must be signed in to change notification settings - Fork 688
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
- We can provide
connectfunction orconnectoptions but not both. Why? - Why
options.originand notoptions.protocol,options.hostandoptions.port? - these checks are missing in RedirectHandler
Lines 100 to 127 in aebbb5d
if (typeof handler.onConnect !== 'function') { throw new InvalidArgumentError('invalid onConnect method') } if (typeof handler.onError !== 'function') { throw new InvalidArgumentError('invalid onError method') } if (typeof handler.onBodySent !== 'function' && handler.onBodySent !== undefined) { throw new InvalidArgumentError('invalid onBodySent method') } if (this.upgrade || this.method === 'CONNECT') { if (typeof handler.onUpgrade !== 'function') { throw new InvalidArgumentError('invalid onUpgrade method') } } else { if (typeof handler.onHeaders !== 'function') { throw new InvalidArgumentError('invalid onHeaders method') } if (typeof handler.onData !== 'function') { throw new InvalidArgumentError('invalid onData method') } if (typeof handler.onComplete !== 'function') { throw new InvalidArgumentError('invalid onComplete method') } - Isn't moot because
Line 130 in aebbb5d
this.servername = util.getServerName(this.host) Line 77 in aebbb5d
this.host = null - nitpick: is slower by ~20% than
Line 1096 in aebbb5d
if (hostname.startsWith('[')) { hostname[0] === '[' - can be removed because ee64b39?
Lines 1397 to 1399 in aebbb5d
// TODO: An HTTP/1.1 user agent MUST NOT preface // or follow a request with an extra CRLF. // https://tools.ietf.org/html/rfc7230#section-3.5 - Can we avoid object allocation somehow? I think that should improve the performance as well. I mean
Lines 1439 to 1449 in aebbb5d
writeStream({ client, request, socket, contentLength, header, expectsPayload }) } else if (util.isStrictIterable(body)) { writeIterable({ client, request, socket, contentLength, header, expectsPayload }) } else { assert(false) } return true } function writeStream ({ client, request, socket, contentLength, header, expectsPayload }) { - this reassures us that there is no body sent on redirect
undici/lib/handler/redirect.js
Line 28 in aebbb5d
// TODO (fix): Write a comment why this is needed? - I wonder if can be removed
Lines 40 to 65 in aebbb5d
if (typeof opts === 'function') { handler = opts opts = null } if (!url || (typeof url !== 'string' && typeof url !== 'object' && !(url instanceof URL))) { throw new InvalidArgumentError('invalid url') } if (opts != null && typeof opts !== 'object') { throw new InvalidArgumentError('invalid opts') } if (opts && opts.path != null) { if (typeof opts.path !== 'string') { throw new InvalidArgumentError('invalid opts.path') } url = new URL(opts.path, util.parseOrigin(url)) } else { if (!opts) { opts = typeof url === 'object' ? url : {} } url = util.parseURL(url) }
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request