@@ -189,7 +189,7 @@ function Framework() {
189189
190190 this . id = null ;
191191 this . version = 1801 ;
192- this . version_header = '1.8.1-6 ' ;
192+ this . version_header = '1.8.1-7 ' ;
193193
194194 var version = process . version . toString ( ) . replace ( 'v' , '' ) . replace ( / \. / g, '' ) ;
195195 if ( version [ 1 ] === '0' )
@@ -257,8 +257,8 @@ function Framework() {
257257 'allow-handle-static-files' : true ,
258258 'allow-gzip' : true ,
259259 'allow-websocket' : true ,
260- 'allow-compile-js ' : true ,
261- 'allow-compile-css ' : true ,
260+ 'allow-compile-script ' : true ,
261+ 'allow-compile-style ' : true ,
262262 'allow-compile-html' : true ,
263263 'allow-performance' : false ,
264264 'allow-custom-titles' : false ,
@@ -683,6 +683,10 @@ Framework.prototype.route = function(url, funcExecute, flags, length, middleware
683683 }
684684 }
685685
686+ var CUSTOM = typeof ( url ) === TYPE_FUNCTION ? url : null ;
687+ if ( CUSTOM )
688+ url = '/' ;
689+
686690 if ( ! skip && typeof ( funcExecute ) === 'string' && flags !== undefined ) {
687691 // ID
688692 name = url ;
@@ -985,6 +989,8 @@ Framework.prototype.route = function(url, funcExecute, flags, length, middleware
985989 isXHR : flags . indexOf ( 'xhr' ) !== - 1 ,
986990 isUPLOAD : flags . indexOf ( 'upload' ) !== - 1 ,
987991 isSYSTEM : url . startsWith ( '/#' ) ,
992+ isCACHE : ! url . startsWith ( '/#' ) && ! CUSTOM && arr . length === 0 && ! isASTERIX ,
993+ CUSTOM : CUSTOM ,
988994 options : options
989995 } ) ;
990996
@@ -1187,6 +1193,10 @@ Framework.prototype.websocket = function(url, funcInitialize, flags, protocols,
11871193
11881194 var tmp ;
11891195
1196+ var CUSTOM = typeof ( url ) === TYPE_FUNCTION ? url : null ;
1197+ if ( CUSTOM )
1198+ url = '/' ;
1199+
11901200 if ( url === '' )
11911201 url = '/' ;
11921202
@@ -1321,6 +1331,7 @@ Framework.prototype.websocket = function(url, funcInitialize, flags, protocols,
13211331 isHTTP : flags . indexOf ( 'http' ) ,
13221332 isDEBUG : flags . indexOf ( 'debug' ) ,
13231333 isRELEASE : flags . indexOf ( 'release' ) ,
1334+ CUSTOM : CUSTOM ,
13241335 middleware : middleware ,
13251336 options : options
13261337 } ) ;
@@ -2572,6 +2583,7 @@ Framework.prototype.usage = function(detailed) {
25722583 output . changes = self . changes ;
25732584 output . files = staticFiles ;
25742585 output . streaming = staticRange ;
2586+ output . other = Object . keys ( self . temporary . other ) ;
25752587 return output ;
25762588} ;
25772589
@@ -2620,14 +2632,14 @@ Framework.prototype.compileContent = function(extension, content, filename) {
26202632
26212633 switch ( extension ) {
26222634 case 'js' :
2623- return self . config [ 'allow-compile-js ' ] ? framework_internal . compile_javascript ( content , filename ) : content ;
2635+ return self . config [ 'allow-compile-script ' ] ? framework_internal . compile_javascript ( content , filename ) : content ;
26242636/*
26252637 case 'html':
26262638 return self.config['allow-compile-html'] ? framework_internal.compile_html(content) : content;
26272639*/
26282640 case 'css' :
26292641
2630- content = self . config [ 'allow-compile-css ' ] ? framework_internal . compile_css ( content , filename ) : content ;
2642+ content = self . config [ 'allow-compile-style ' ] ? framework_internal . compile_css ( content , filename ) : content ;
26312643
26322644 var matches = content . match ( / u r l \( .* ?\) / g) ;
26332645 if ( matches === null )
@@ -4401,7 +4413,7 @@ Framework.prototype._service = function(count) {
44014413 gc ( ) ;
44024414 }
44034415
4404- // every 3 minutes (default) service clears static cache
4416+ // every 7 minutes (default) service clears static cache
44054417 if ( count % framework . config [ 'default-interval-clear-cache' ] === 0 ) {
44064418 self . emit ( 'clear' , 'temporary' , self . temporary ) ;
44074419 self . temporary . path = { } ;
@@ -4423,7 +4435,6 @@ Framework.prototype._service = function(count) {
44234435
44244436 var ping = framework . config [ 'default-interval-websocket-ping' ] ;
44254437 if ( ping > 0 && count % ping === 0 ) {
4426- // every 1 minute (default) is created a ping message
44274438 Object . keys ( framework . connections ) . wait ( function ( item , next ) {
44284439 var conn = framework . connections [ item ] ;
44294440 if ( conn && typeof ( conn . ping ) === TYPE_FUNCTION )
@@ -4609,6 +4620,7 @@ Framework.prototype._request_continue = function(req, res, headers, protocol) {
46094620 req . buffer_exceeded = false ;
46104621 req . buffer_data = new Buffer ( '' ) ;
46114622 req . buffer_has = false ;
4623+ req . $flags = '' ;
46124624
46134625 var accept = headers . accept ;
46144626
@@ -4617,39 +4629,55 @@ Framework.prototype._request_continue = function(req, res, headers, protocol) {
46174629 var flags = [ req . method . toLowerCase ( ) ] ;
46184630 var multipart = req . headers [ 'content-type' ] || '' ;
46194631
4632+ req . $flags += protocol ;
46204633 flags . push ( protocol ) ;
46214634
46224635 if ( multipart . indexOf ( '/form-data' ) === - 1 ) {
46234636
4624- if ( multipart . indexOf ( '/json' ) !== - 1 )
4637+ if ( multipart . indexOf ( '/json' ) !== - 1 ) {
4638+ req . $flags += 'json' ;
46254639 flags . push ( 'json' ) ;
4626- else if ( multipart . indexOf ( '/xml' ) !== - 1 )
4640+ }
4641+ else if ( multipart . indexOf ( '/xml' ) !== - 1 ) {
4642+ req . $flags += 'xml' ;
46274643 flags . push ( 'xml' ) ;
4644+ }
46284645
46294646 multipart = '' ;
46304647 }
46314648
4632- if ( multipart . length > 0 )
4649+ if ( multipart . length > 0 ) {
4650+ req . $flags += 'upload' ;
46334651 flags . push ( 'upload' ) ;
4652+ }
46344653
4635- if ( req . isProxy )
4654+ if ( req . isProxy ) {
4655+ req . $flags += 'proxy' ;
46364656 flags . push ( 'proxy' ) ;
4657+ }
46374658
4638- if ( accept === 'text/event-stream' )
4659+ if ( accept === 'text/event-stream' ) {
4660+ req . $flags += 'sse' ;
46394661 flags . push ( 'sse' ) ;
4662+ }
46404663
4641- if ( self . config . debug )
4664+ if ( self . config . debug ) {
4665+ req . $flags += 'debug' ;
46424666 flags . push ( 'debug' ) ;
4667+ }
46434668
46444669 if ( req . xhr ) {
46454670 self . stats . request . xhr ++ ;
4671+ req . $flags += 'xhr' ;
46464672 flags . push ( 'xhr' ) ;
46474673 }
46484674
46494675 if ( self . _request_check_referer ) {
46504676 var referer = headers [ 'referer' ] || '' ;
4651- if ( referer !== '' && referer . indexOf ( headers [ 'host' ] ) !== - 1 )
4677+ if ( referer !== '' && referer . indexOf ( headers [ 'host' ] ) !== - 1 ) {
4678+ req . $flags += 'referer' ;
46524679 flags . push ( 'referer' ) ;
4680+ }
46534681 }
46544682
46554683 req . flags = flags ;
@@ -4819,6 +4847,7 @@ Framework.prototype._upgrade_prepare = function(req, path, headers) {
48194847 req . user = user ;
48204848
48214849 req . flags . push ( isLogged ? 'authorize' : 'unauthorize' ) ;
4850+
48224851 var route = self . lookup_websocket ( req , req . websocket . uri . pathname , false ) ;
48234852 if ( route === null ) {
48244853 req . websocket . close ( ) ;
@@ -5891,12 +5920,22 @@ Framework.prototype._configure = function(arr, rewrite) {
58915920 obj [ name ] [ tmp [ j ] ] = true ;
58925921 break ;
58935922
5894- case 'allow-gzip' :
5895- case 'allow-websocket' :
58965923 case 'allow-compile-js' :
5924+ console . log ( 'CONFIG: allow-compile-js is obsolete, use: allow-compile-script' ) ;
5925+ obj [ 'allow-compile-script' ] = value . toLowerCase ( ) === 'true' || value === '1' || value === 'on' ;
5926+ break ;
5927+
58975928 case 'allow-compile-css' :
5898- case 'allow-compile-html' :
5929+ console . log ( 'CONFIG: allow-compile-css is obsolete, use: allow-compile-style' ) ;
5930+ obj [ 'allow-compile-style' ] = value . toLowerCase ( ) === 'true' || value === '1' || value === 'on' ;
5931+ break ;
5932+
5933+ case 'allow-gzip' :
5934+ case 'allow-websocket' :
58995935 case 'allow-performance' :
5936+ case 'allow-compile-html' :
5937+ case 'allow-compile-style' :
5938+ case 'allow-compile-script' :
59005939 case 'disable-strict-server-certificate-validation' :
59015940 case 'disable-clear-temporary-directory' :
59025941 obj [ name ] = value . toLowerCase ( ) === 'true' || value === '1' || value === 'on' ;
@@ -6082,38 +6121,50 @@ Framework.prototype.lookup = function(req, url, flags, noLoggedUnlogged) {
60826121 // helper for 401 http status
60836122 req . $isAuthorized = true ;
60846123
6124+ var key = '#route' + url + '$' + req . $flags ;
6125+ if ( framework . temporary . other [ key ] )
6126+ return framework . temporary . other [ key ] ;
6127+
60856128 var length = self . routes . web . length ;
60866129 for ( var i = 0 ; i < length ; i ++ ) {
60876130
60886131 var route = self . routes . web [ i ] ;
60896132
6090- if ( ! framework_internal . routeCompareSubdomain ( subdomain , route . subdomain ) )
6091- continue ;
6092-
6093- if ( route . isASTERIX ) {
6094- if ( ! framework_internal . routeCompare ( req . path , route . url , isSystem , true ) )
6133+ if ( route . CUSTOM ) {
6134+ if ( ! route . CUSTOM ( url , req , flags ) )
60956135 continue ;
60966136 } else {
6097- if ( ! framework_internal . routeCompare ( req . path , route . url , isSystem ) )
6137+ if ( ! framework_internal . routeCompareSubdomain ( subdomain , route . subdomain ) )
60986138 continue ;
6139+
6140+ if ( route . isASTERIX ) {
6141+ if ( ! framework_internal . routeCompare ( req . path , route . url , isSystem , true ) )
6142+ continue ;
6143+ } else {
6144+ if ( ! framework_internal . routeCompare ( req . path , route . url , isSystem ) )
6145+ continue ;
6146+ }
60996147 }
61006148
61016149 if ( isSystem ) {
6102- if ( route . isSYSTEM )
6150+ if ( route . isSYSTEM ) {
6151+ framework . temporary . other [ key ] = route ;
61036152 return route ;
6153+ }
61046154 continue ;
61056155 }
61066156
61076157 if ( route . flags !== null && route . flags . length > 0 ) {
6108-
61096158 var result = framework_internal . routeCompareFlags2 ( req , route , noLoggedUnlogged ? true : route . isMEMBER ) ;
61106159 if ( result === - 1 )
61116160 req . $isAuthorized = false ; // request is not authorized
6112-
61136161 if ( result < 1 )
61146162 continue ;
61156163 }
61166164
6165+ if ( route . isCACHE && req . $isAuthorized )
6166+ framework . temporary . other [ key ] = route ;
6167+
61176168 return route ;
61186169 }
61196170
@@ -6137,15 +6188,21 @@ Framework.prototype.lookup_websocket = function(req, url, noLoggedUnlogged) {
61376188 for ( var i = 0 ; i < length ; i ++ ) {
61386189
61396190 var route = self . routes . websockets [ i ] ;
6140- if ( ! framework_internal . routeCompareSubdomain ( subdomain , route . subdomain ) )
6141- continue ;
61426191
6143- if ( route . isASTERIX ) {
6144- if ( ! framework_internal . routeCompare ( req . path , route . url , false , true ) )
6192+ if ( route . CUSTOM ) {
6193+ if ( ! route . CUSTOM ( url , req ) )
61456194 continue ;
61466195 } else {
6147- if ( ! framework_internal . routeCompare ( req . path , route . url , false ) )
6196+ if ( ! framework_internal . routeCompareSubdomain ( subdomain , route . subdomain ) )
61486197 continue ;
6198+
6199+ if ( route . isASTERIX ) {
6200+ if ( ! framework_internal . routeCompare ( req . path , route . url , false , true ) )
6201+ continue ;
6202+ } else {
6203+ if ( ! framework_internal . routeCompare ( req . path , route . url , false ) )
6204+ continue ;
6205+ }
61496206 }
61506207
61516208 if ( route . flags !== null && route . flags . length > 0 ) {
@@ -7501,8 +7558,10 @@ Subscribe.prototype.doAuthorization = function(isLogged, user) {
75017558
75027559 var self = this ;
75037560 var req = self . req ;
7561+ var auth = isLogged ? 'authorize' : 'unauthorize' ;
75047562
7505- req . flags . push ( isLogged ? 'authorize' : 'unauthorize' ) ;
7563+ req . flags . push ( auth ) ;
7564+ req . $flags += auth ;
75067565
75077566 if ( user )
75087567 req . user = user ;
0 commit comments