@@ -586,6 +586,8 @@ function RegistryClientV2(opts) {
586
586
this . _url = common . urlFromIndex ( this . repo . index ) ;
587
587
}
588
588
589
+ this . _clientsToClose = [ ] ;
590
+
589
591
Object . defineProperty ( this , '_api' , {
590
592
get : function ( ) {
591
593
if ( self . __api === undefined ) {
@@ -596,13 +598,28 @@ function RegistryClientV2(opts) {
596
598
rejectUnauthorized : ! this . insecure ,
597
599
userAgent : self . userAgent
598
600
} ) ;
601
+ self . _clientsToClose . push ( self . __api ) ;
599
602
}
600
603
return this . __api ;
601
604
}
602
605
} ) ;
603
606
}
604
607
605
608
609
+ RegistryClientV2 . prototype . version = 2 ;
610
+
611
+
612
+ RegistryClientV2 . prototype . close = function close ( ) {
613
+ for ( var i = 0 ; i < this . _clientsToClose . length ; i ++ ) {
614
+ var client = this . _clientsToClose [ i ] ;
615
+ this . log . trace ( { host : client . url && client . url . host } ,
616
+ 'close http client' ) ;
617
+ client . close ( ) ;
618
+ }
619
+ this . _clientsToClose = [ ] ;
620
+ } ;
621
+
622
+
606
623
/**
607
624
* Get a registry session token from docker.io.
608
625
*
@@ -714,18 +731,6 @@ RegistryClientV2.prototype._login = function _login(cb) {
714
731
} ) ;
715
732
} ;
716
733
717
- RegistryClientV2 . prototype . version = 2 ;
718
-
719
-
720
- RegistryClientV2 . prototype . close = function close ( ) {
721
- if ( this . __api ) {
722
- this . __api . close ( ) ;
723
- }
724
- if ( this . __rawApi ) {
725
- this . __rawApi . close ( ) ;
726
- }
727
- } ;
728
-
729
734
730
735
//RegistryClientV2.prototype._saveCookies = function _saveCookies(url, res) {
731
736
// var header = res.headers['set-cookie'];
@@ -947,10 +952,12 @@ RegistryClientV2.prototype._headOrGetBlob = function _headOrGetBlob(opts, cb) {
947
952
var client = restify . createHttpClient ( {
948
953
url : reqOpts . url ,
949
954
log : self . log ,
950
- agent : false ,
955
+ // XXX common opts: agent, proxy
951
956
rejectUnauthorized : ! self . insecure ,
952
957
userAgent : self . userAgent
953
958
} ) ;
959
+ self . _clientsToClose . push ( client ) ;
960
+
954
961
client [ opts . method ] ( reqOpts , function _onConn ( connErr , req ) {
955
962
if ( connErr ) {
956
963
next ( connErr ) ;
0 commit comments