@@ -1491,85 +1491,3 @@ exports.Client = Client;
14911491exports . createClient = function ( port , host ) {
14921492 return new Client ( port , host ) ;
14931493} ;
1494-
1495- exports . cat = function ( url , encoding_ , headers_ ) {
1496- var encoding = 'utf8' ;
1497- var headers = { } ;
1498- var callback = null ;
1499-
1500- console . error ( "http.cat will be removed in the near future. use http.get" ) ;
1501-
1502- // parse the arguments for the various options... very ugly
1503- if ( typeof ( arguments [ 1 ] ) == 'string' ) {
1504- encoding = arguments [ 1 ] ;
1505- if ( typeof ( arguments [ 2 ] ) == 'object' ) {
1506- headers = arguments [ 2 ] ;
1507- if ( typeof ( arguments [ 3 ] ) == 'function' ) callback = arguments [ 3 ] ;
1508- } else {
1509- if ( typeof ( arguments [ 2 ] ) == 'function' ) callback = arguments [ 2 ] ;
1510- }
1511- } else {
1512- // didn't specify encoding
1513- if ( typeof ( arguments [ 1 ] ) == 'object' ) {
1514- headers = arguments [ 1 ] ;
1515- callback = arguments [ 2 ] ;
1516- } else {
1517- callback = arguments [ 1 ] ;
1518- }
1519- }
1520-
1521- var url = require ( 'url' ) . parse ( url ) ;
1522-
1523- var hasHost = false ;
1524- if ( Array . isArray ( headers ) ) {
1525- for ( var i = 0 , l = headers . length ; i < l ; i ++ ) {
1526- if ( headers [ i ] [ 0 ] . toLowerCase ( ) === 'host' ) {
1527- hasHost = true ;
1528- break ;
1529- }
1530- }
1531- } else if ( typeof headers === 'Object' ) {
1532- var keys = Object . keys ( headers ) ;
1533- for ( var i = 0 , l = keys . length ; i < l ; i ++ ) {
1534- var key = keys [ i ] ;
1535- if ( key . toLowerCase ( ) == 'host' ) {
1536- hasHost = true ;
1537- break ;
1538- }
1539- }
1540- }
1541- if ( ! hasHost ) headers [ 'Host' ] = url . hostname ;
1542-
1543- var content = '' ;
1544-
1545- var path = ( url . pathname || '/' ) + ( url . search || '' ) + ( url . hash || '' ) ;
1546- var callbackSent = false ;
1547- var req = exports . request ( { port : url . port || 80 , host : url . hostname , path : path } , function ( res ) {
1548- if ( res . statusCode < 200 || res . statusCode >= 300 ) {
1549- if ( callback && ! callbackSent ) {
1550- callback ( res . statusCode ) ;
1551- callbackSent = true ;
1552- }
1553- client . end ( ) ;
1554- return ;
1555- }
1556- res . setEncoding ( encoding ) ;
1557- res . addListener ( 'data' , function ( chunk ) { content += chunk ; } ) ;
1558- res . addListener ( 'end' , function ( ) {
1559- if ( callback && ! callbackSent ) {
1560- callback ( null , content ) ;
1561- callbackSent = true ;
1562- }
1563- } ) ;
1564- } ) ;
1565-
1566-
1567- req . addListener ( 'error' , function ( err ) {
1568- if ( callback && ! callbackSent ) {
1569- callback ( err ) ;
1570- callbackSent = true ;
1571- }
1572- } ) ;
1573-
1574- req . end ( ) ;
1575- } ;
0 commit comments