@@ -27,6 +27,7 @@ import * as semver from 'semver';
27
27
28
28
import { plugin } from '../src/' ;
29
29
import { Http2Plugin } from '../src/' ;
30
+ import { URL } from 'url' ;
30
31
31
32
const VERSION = process . versions . node ;
32
33
@@ -101,9 +102,11 @@ describe('Http2Plugin', () => {
101
102
102
103
let server : http2 . Http2Server ;
103
104
let client : http2 . ClientHttp2Session ;
105
+ let client2 : http2 . ClientHttp2Session ;
104
106
const serverPort = 8080 ;
105
107
const host = `localhost:${ serverPort } ` ;
106
108
const authority = `http://${ host } ` ;
109
+ const authorityUrlObject = new URL ( '/' , `http://${ host } /` ) ;
107
110
108
111
const log = logger . logger ( ) ;
109
112
const tracer = new CoreTracer ( ) ;
@@ -131,6 +134,7 @@ describe('Http2Plugin', () => {
131
134
server . listen ( serverPort ) ;
132
135
133
136
client = http2 . connect ( authority ) ;
137
+ client2 = http2 . connect ( authorityUrlObject ) ;
134
138
} ) ;
135
139
136
140
beforeEach ( ( ) => {
@@ -140,6 +144,7 @@ describe('Http2Plugin', () => {
140
144
after ( ( ) => {
141
145
server . close ( ) ;
142
146
client . destroy ( ) ;
147
+ client2 . destroy ( ) ;
143
148
} ) ;
144
149
145
150
/** Should intercept outgoing requests */
@@ -167,6 +172,24 @@ describe('Http2Plugin', () => {
167
172
} ) ;
168
173
} ) ;
169
174
175
+ it ( 'should succeed when the client is connected using the url.URL object (#640)' , async ( ) => {
176
+ const statusCode = 200 ;
177
+ const testPath = `/${ statusCode } ` ;
178
+ const requestOptions = {
179
+ ':method' : 'GET' ,
180
+ ':path' : testPath ,
181
+ } ;
182
+
183
+ assert . strictEqual ( spanVerifier . endedSpans . length , 0 ) ;
184
+
185
+ await http2Request . get ( client2 , requestOptions ) . then ( result => {
186
+ assert . strictEqual ( result , statusCode . toString ( ) ) ;
187
+ assert . strictEqual ( spanVerifier . endedSpans . length , 2 ) ;
188
+ const span = spanVerifier . endedSpans [ 1 ] ;
189
+ assertSpanAttributes ( span , statusCode , 'GET' , host , testPath ) ;
190
+ } ) ;
191
+ } ) ;
192
+
170
193
const httpErrorCodes = [ 400 , 401 , 403 , 404 , 429 , 501 , 503 , 504 , 500 ] ;
171
194
172
195
httpErrorCodes . map ( errorCode => {
0 commit comments