@@ -55,6 +55,7 @@ var POWEREDBY = '...';
5555var REQUEST_COMPRESS_CONTENTTYPE = { 'text/plain' : true , 'text/javascript' : true , 'text/css' : true , 'text/jsx' : true , 'application/x-javascript' : true , 'application/json' : true , 'text/xml' : true , 'image/svg+xml' : true , 'text/x-markdown' : true , 'text/html' : true } ;
5656var TEMPORARY_KEY_REGEX = / \/ / g;
5757var REG_MOBILE = / A n d r o i d | w e b O S | i P h o n e | i P a d | i P o d | B l a c k B e r r y | I E M o b i l e | O p e r a M i n i | M o b i l e | T a b l e t / i;
58+ var REG_ROBOT = / s e a r c h | a g e n t | b o t | c r a w l e r / i;
5859var REG_VERSIONS = / ( h r e f | s r c ) = " [ a - z A - Z 0 - 9 \/ \: \- \. ] + \. ( j p g | j s | c s s | p n g | g i f | s v g | h t m l | i c o | j s o n | l e s s | s a s s | s c s s | s w f | t x t | w e b p | w o f f | w o f f 2 | x l s | x l s x | x m l | x s l | x s l t | z i p | r a r | c s v | d o c | d o c x | e p s | g z i p | j p e | j p e g | m a n i f e s t | m o v | m p 3 | m p 4 | o g g | p a c k a g e | p d f ) " / gi;
5960var REG_MULTIPART = / \/ f o r m \- d a t a $ / i;
6061var REQUEST_PROXY_FLAGS = [ 'post' , 'json' ] ;
@@ -415,7 +416,7 @@ function Framework() {
415416
416417 this . id = null ;
417418 this . version = 1960 ;
418- this . version_header = '1.9.6-17 ' ;
419+ this . version_header = '1.9.6-18 ' ;
419420
420421 var version = process . version . toString ( ) . replace ( 'v' , '' ) . replace ( / \. / g, '' ) ;
421422 if ( version [ 0 ] !== '0' || version [ 1 ] !== '0' )
@@ -638,7 +639,7 @@ function Framework() {
638639 this . _request_check_redirect = false ;
639640 this . _request_check_referer = false ;
640641 this . _request_check_POST = false ;
641- this . _request_check_mobile = false ;
642+ this . _request_check_robot = false ;
642643 this . _length_middleware = 0 ;
643644 this . _length_request_middleware = 0 ;
644645 this . _length_files = 0 ;
@@ -758,6 +759,7 @@ Framework.prototype._routesSort = function() {
758759
759760 var cache = { } ;
760761 var length = self . routes . web . length ;
762+ var url ;
761763
762764 for ( var i = 0 ; i < length ; i ++ ) {
763765 var route = self . routes . web [ i ] ;
@@ -770,7 +772,7 @@ Framework.prototype._routesSort = function() {
770772 continue ;
771773 if ( route . flags . indexOf ( 'get' ) === - 1 )
772774 continue ;
773- var url = route . url . join ( '/' ) ;
775+ url = route . url . join ( '/' ) ;
774776 cache [ url ] = true ;
775777 }
776778
@@ -780,7 +782,7 @@ Framework.prototype._routesSort = function() {
780782 continue ;
781783 if ( route . flags . indexOf ( 'get' ) === - 1 )
782784 continue ;
783- var url = route . url . join ( '/' ) ;
785+ url = route . url . join ( '/' ) ;
784786 route . isMOBILE_VARY = cache [ url ] === true ;
785787 }
786788
@@ -1219,6 +1221,7 @@ Framework.prototype.route = function(url, funcExecute, flags, length, middleware
12191221 var isMOBILE = false ;
12201222 var isJSON = false ;
12211223 var isDELAY = false ;
1224+ var isROBOT = false ;
12221225
12231226 if ( flags ) {
12241227
@@ -1302,7 +1305,10 @@ Framework.prototype.route = function(url, funcExecute, flags, length, middleware
13021305 break ;
13031306 case 'mobile' :
13041307 isMOBILE = true ;
1305- self . _request_check_mobile = true ;
1308+ break ;
1309+ case 'robot' :
1310+ isROBOT = true ;
1311+ self . _request_check_robot = true ;
13061312 break ;
13071313 case 'authorize' :
13081314 case 'authorized' :
@@ -1465,6 +1471,7 @@ Framework.prototype.route = function(url, funcExecute, flags, length, middleware
14651471 isXML : flags . indexOf ( 'xml' ) !== - 1 ,
14661472 isRAW : isRaw ,
14671473 isMOBILE : isMOBILE ,
1474+ isROBOT : isROBOT ,
14681475 isMOBILE_VARY : isMOBILE ,
14691476 isGENERATOR : isGENERATOR ,
14701477 isMEMBER : isMember ,
@@ -6270,7 +6277,7 @@ Framework.prototype._upgrade = function(req, socket, head) {
62706277
62716278 req . session = null ;
62726279 req . user = null ;
6273- req . flags = [ req . isSecure ? 'https' : 'http' , 'get' ] ;
6280+ req . flags = [ req . secured ? 'https' : 'http' , 'get' ] ;
62746281
62756282 var path = framework_utils . path ( req . uri . pathname ) ;
62766283 var websocket = new WebSocketClient ( req , socket , head ) ;
@@ -9895,6 +9902,10 @@ Controller.prototype = {
98959902 return this . req . isSecure ;
98969903 } ,
98979904
9905+ get secured ( ) {
9906+ return this . req . secured ;
9907+ } ,
9908+
98989909 get session ( ) {
98999910 return this . req . session ;
99009911 } ,
@@ -9919,6 +9930,14 @@ Controller.prototype = {
99199930 framework . global = value ;
99209931 } ,
99219932
9933+ get mobile ( ) {
9934+ return this . req . mobile ;
9935+ } ,
9936+
9937+ get robot ( ) {
9938+ return this . req . robot ;
9939+ } ,
9940+
99229941 get async ( ) {
99239942
99249943 var self = this ;
@@ -12928,6 +12947,10 @@ WebSocket.prototype = {
1292812947 return this . req . isSecure ;
1292912948 } ,
1293012949
12950+ get secured ( ) {
12951+ return this . req . secured ;
12952+ } ,
12953+
1293112954 get async ( ) {
1293212955
1293312956 var self = this ;
@@ -14449,6 +14472,11 @@ http.IncomingMessage.prototype = {
1444914472 } ,
1445014473
1445114474 get isSecure ( ) {
14475+ OBSOLETE ( 'req.isSecure' , 'Use req.secured' ) ;
14476+ return this . uri . protocol === 'https:' || this . uri . protocol === 'wss:' ;
14477+ } ,
14478+
14479+ get secured ( ) {
1445214480 return this . uri . protocol === 'https:' || this . uri . protocol === 'wss:' ;
1445314481 } ,
1445414482
@@ -14464,6 +14492,12 @@ http.IncomingMessage.prototype = {
1446414492 return this . $mobile ;
1446514493 } ,
1446614494
14495+ get robot ( ) {
14496+ if ( this . $robot === undefined )
14497+ this . $robot = REG_ROBOT . test ( this . headers [ 'user-agent' ] ) ;
14498+ return this . $robot ;
14499+ } ,
14500+
1446714501 set language ( value ) {
1446814502 this . $language = value ;
1446914503 }
0 commit comments