http2-wrapper
Advanced tools
Comparing version 0.3.1 to 0.3.2
{ | ||
"name": "http2-wrapper", | ||
"version": "0.3.1", | ||
"version": "0.3.2", | ||
"description": "Use HTTP2 the same way like HTTP1", | ||
@@ -47,4 +47,5 @@ "main": "source", | ||
"dependencies": { | ||
"defer-to-connect": "^1.0.0" | ||
"defer-to-connect": "^1.0.0", | ||
"url-parse-lax": "^3.0.0" | ||
} | ||
} |
@@ -5,2 +5,3 @@ 'use strict'; | ||
const deferToConnect = require('defer-to-connect'); | ||
const urlParseLax = require('url-parse-lax'); | ||
const HTTP2IncomingMessage = require('./HTTP2IncomingMessage'); | ||
@@ -26,2 +27,4 @@ const proxySocket = require('./proxySocket'); | ||
const normalizePort = (port, protocol) => port ? port : (protocol === 'http:' ? 80 : 443); | ||
class HTTP2ClientRequest extends Writable { | ||
@@ -37,11 +40,8 @@ constructor(options, cb) { | ||
// Accepts custom authority | ||
if (options.authority) { | ||
const parsed = new URL(options.authority); | ||
options.port = parsed.port; | ||
options.hostname = parsed.hostname; | ||
options.host = parsed.hostname; | ||
if (typeof options.authority === 'string') { | ||
options.authority = urlParseLax(options.authority); | ||
} else { | ||
// We should normalize options.port on our own, | ||
// because the TLS API and HTTP2 API normalize it in a different way. | ||
options.port = options.port ? options.port : (options.protocol === 'http:' ? 80 : 443); | ||
options.port = normalizePort(options.port, options.protocol); | ||
} | ||
@@ -62,3 +62,5 @@ } | ||
this.session = http2.connect(options.authority || options, options); | ||
const {authority} = options; | ||
const normalizedAuthority = authority ? `${authority.protocol}//${authority.hostname}:${normalizePort(authority.port, authority.protocol)}` : options; | ||
this.session = http2.connect(normalizedAuthority, {...options, host: options.hostname, path: undefined, session: undefined}); | ||
} | ||
@@ -65,0 +67,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18795
420
2
+ Addedurl-parse-lax@^3.0.0
+ Addedprepend-http@2.0.0(transitive)
+ Addedurl-parse-lax@3.0.0(transitive)