@@ -24,7 +24,7 @@ import FakeTimers from '@sinonjs/fake-timers'
2424import { buildServer , connection } from '../utils'
2525import { Client , errors } from '../..'
2626import * as symbols from '@elastic/transport/lib/symbols'
27- import { BaseConnectionPool , CloudConnectionPool , WeightedConnectionPool } from '@elastic/transport'
27+ import { BaseConnectionPool , CloudConnectionPool , WeightedConnectionPool , HttpConnection } from '@elastic/transport'
2828
2929let clientVersion : string = require ( '../../package.json' ) . version // eslint-disable-line
3030if ( clientVersion . includes ( '-' ) ) {
@@ -403,6 +403,44 @@ test('Meta header disabled', async t => {
403403 await client . transport . request ( { method : 'GET' , path : '/' } )
404404} )
405405
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+
406444test ( 'caFingerprint' , t => {
407445 const client = new Client ( {
408446 node : 'https://localhost:9200' ,
0 commit comments