PageCache should writeHeaders

This commit is contained in:
斟酌 鵬兄 2016-10-25 17:52:20 +08:00
parent 3c347df812
commit a7edb55d4c
2 changed files with 10 additions and 5 deletions

View File

@ -59,7 +59,7 @@ class WebFrame
res.statusCode = 301;
res.headers[ "Location" ] = router.relaying.params[0];
_self.result = "";
_self.plantResult();
_self.plantResult( true );
}
, "302": function()
{

View File

@ -35,16 +35,21 @@ class PageCache
var expires = new Date().getTime() + 1000 * ttl;
this.cache[ key ] = {
var c = {
data: data
, headers: {
"Content-Length": res.headers[ "Content-Length" ]
, "Content-Type": res.headers[ "Content-Type" ]
, "X-Cache-Expires": new Date( expires )
}
, statusCode: res.statusCode
, ttl: expires
};
if( res.headers[ "Location" ] )
c.headers[ "Location" ] = res.headers[ "Location" ];
this.cache[ key ] = c;
Dragonfly.Debug( "StoreCache: \"" + key + "\", expire " + new Date( expires ) );
}
@ -76,9 +81,9 @@ class PageCache
);
var c = this.cache[ url ];
res.headers = c.headers;
res.write( c.data );
res.end();
res.writeHead( c.statusCode, c.headers );
res.end( c.data );
return true;
}