@@ -25,7 +25,7 @@ import FakeTimers from '@sinonjs/fake-timers'
25
25
import { buildServer , connection } from '../utils'
26
26
import { Client , errors } from '../..'
27
27
import * as symbols from '@elastic/transport/lib/symbols'
28
- import { BaseConnectionPool , CloudConnectionPool , WeightedConnectionPool } from '@elastic/transport'
28
+ import { BaseConnectionPool , CloudConnectionPool , WeightedConnectionPool , HttpConnection } from '@elastic/transport'
29
29
30
30
let clientVersion : string = require ( '../../package.json' ) . version // eslint-disable-line
31
31
if ( clientVersion . includes ( '-' ) ) {
@@ -404,6 +404,44 @@ test('Meta header disabled', async t => {
404
404
await client . transport . request ( { method : 'GET' , path : '/' } )
405
405
} )
406
406
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
+
407
445
test ( 'caFingerprint' , t => {
408
446
const client = new Client ( {
409
447
node : 'https://localhost:9200' ,
0 commit comments