@@ -1833,3 +1833,58 @@ describe('Client posting complex body', () => {
18331833 } , baseUrl ) ;
18341834 } ) ;
18351835} ) ;
1836+
1837+ describe ( 'Connection header' , ( ) => {
1838+ var server = null ;
1839+ var hostname = '127.0.0.1' ;
1840+ var port = 15099 ;
1841+ var baseUrl = 'http://' + hostname + ':' + port ;
1842+
1843+ before ( function ( done ) {
1844+ server = http . createServer ( function ( req , res ) {
1845+ res . statusCode = 200 ;
1846+ res . write ( JSON . stringify ( { tempResponse : 'temp' } ) , 'utf8' ) ;
1847+ res . end ( ) ;
1848+ } ) . listen ( port , hostname , done ) ;
1849+ } ) ;
1850+
1851+ after ( function ( done ) {
1852+ server . close ( ) ;
1853+ server = null ;
1854+ done ( ) ;
1855+ } ) ;
1856+
1857+ it ( 'should set Connection header to keep-alive when forever option is true' , function ( done ) {
1858+ soap . createClient ( __dirname + '/wsdl/default_namespace.wsdl' , function ( err , client ) {
1859+ assert . ok ( client ) ;
1860+ assert . ifError ( err ) ;
1861+ client . MyOperation ( { } , { forever : true } , function ( ) {
1862+ assert . strictEqual ( client . lastRequestHeaders . Connection , 'keep-alive' ) ;
1863+ done ( ) ;
1864+ } , null , null ) ;
1865+ } , baseUrl ) ;
1866+ } ) ;
1867+
1868+ it ( 'should not set Connection header when forever option is false' , function ( done ) {
1869+ soap . createClient ( __dirname + '/wsdl/default_namespace.wsdl' , function ( err , client ) {
1870+ assert . ok ( client ) ;
1871+ assert . ifError ( err ) ;
1872+ client . MyOperation ( { } , { forever : false } , function ( ) {
1873+ assert . strictEqual ( client . lastRequestHeaders . Connection , undefined ) ;
1874+ done ( ) ;
1875+ } , null , null ) ;
1876+ } , baseUrl ) ;
1877+ } ) ;
1878+
1879+ it ( 'should not set Connection header when forever option is not set' , function ( done ) {
1880+ soap . createClient ( __dirname + '/wsdl/default_namespace.wsdl' , function ( err , client ) {
1881+ assert . ok ( client ) ;
1882+ assert . ifError ( err ) ;
1883+
1884+ client . MyOperation ( { } , function ( ) {
1885+ assert . strictEqual ( client . lastRequestHeaders . Connection , undefined ) ;
1886+ done ( ) ;
1887+ } , null , null ) ;
1888+ } , baseUrl ) ;
1889+ } ) ;
1890+ } ) ;
0 commit comments