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