@@ -24,7 +24,7 @@ import FakeTimers from '@sinonjs/fake-timers'
24
24
import { buildServer , connection } from '../utils'
25
25
import { Client , errors } from '../..'
26
26
import * as symbols from '@elastic/transport/lib/symbols'
27
- import { BaseConnectionPool , CloudConnectionPool , WeightedConnectionPool } from '@elastic/transport'
27
+ import { BaseConnectionPool , CloudConnectionPool , WeightedConnectionPool , HttpConnection } from '@elastic/transport'
28
28
29
29
let clientVersion : string = require ( '../../package.json' ) . version // eslint-disable-line
30
30
if ( clientVersion . includes ( '-' ) ) {
@@ -403,6 +403,44 @@ test('Meta header disabled', async t => {
403
403
await client . transport . request ( { method : 'GET' , path : '/' } )
404
404
} )
405
405
406
+ test ( 'Meta header indicates when UndiciConnection is used' , async t => {
407
+ t . plan ( 1 )
408
+
409
+ function handler ( req : http . IncomingMessage , res : http . ServerResponse ) {
410
+ t . equal ( req . headers [ 'x-elastic-client-meta' ] , `es=${ clientVersion } ,js=${ nodeVersion } ,t=${ transportVersion } ,un=${ nodeVersion } ` )
411
+ res . end ( 'ok' )
412
+ }
413
+
414
+ const [ { port } , server ] = await buildServer ( handler )
415
+
416
+ const client = new Client ( {
417
+ node : `http://localhost:${ port } ` ,
418
+ // Connection: UndiciConnection is the default
419
+ } )
420
+
421
+ await client . transport . request ( { method : 'GET' , path : '/' } )
422
+ server . stop ( )
423
+ } )
424
+
425
+ test ( 'Meta header indicates when HttpConnection is used' , async t => {
426
+ t . plan ( 1 )
427
+
428
+ function handler ( req : http . IncomingMessage , res : http . ServerResponse ) {
429
+ t . equal ( req . headers [ 'x-elastic-client-meta' ] , `es=${ clientVersion } ,js=${ nodeVersion } ,t=${ transportVersion } ,hc=${ nodeVersion } ` )
430
+ res . end ( 'ok' )
431
+ }
432
+
433
+ const [ { port } , server ] = await buildServer ( handler )
434
+
435
+ const client = new Client ( {
436
+ node : `http://localhost:${ port } ` ,
437
+ Connection : HttpConnection ,
438
+ } )
439
+
440
+ await client . transport . request ( { method : 'GET' , path : '/' } )
441
+ server . stop ( )
442
+ } )
443
+
406
444
test ( 'caFingerprint' , t => {
407
445
const client = new Client ( {
408
446
node : 'https://localhost:9200' ,
0 commit comments