mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-30 11:10:24 +00:00
fix(main) generate headers: last-modified
This commit is contained in:
parent
e2dbbf9019
commit
fe5475f126
1 changed files with 34 additions and 15 deletions
|
|
@ -11,7 +11,7 @@
|
|||
SLASH,
|
||||
ISWIN32,
|
||||
ext,
|
||||
path, fs, zlib, url, pipe, CloudFunc, diffPatch, querystring,
|
||||
path, fs, zlib, url, pipe, CloudFunc, diffPatch, querystring, time,
|
||||
|
||||
OK, FILE_NOT_FOUND, MOVED_PERMANENTLY,
|
||||
REQUEST, RESPONSE,
|
||||
|
|
@ -114,7 +114,7 @@
|
|||
exports.hash = srvrequire('hash'),
|
||||
diffPatch = librequire('diff/diff-match-patch').diff_match_patch,
|
||||
exports.diff = new (librequire('diff').DiffProto)(diffPatch),
|
||||
exports.time = srvrequire('time');
|
||||
exports.time = time = srvrequire('time');
|
||||
exports.users = srvrequire('users');
|
||||
exports.rest = srvrequire('rest').api,
|
||||
exports.update = srvrequire('update'),
|
||||
|
|
@ -218,10 +218,13 @@
|
|||
header = {
|
||||
'Access-Control-Allow-Origin' : '*',
|
||||
'Content-Type' : type + encoding,
|
||||
//'Last-Modified' : '' + new Date(),
|
||||
'Vary' : 'Accept-Encoding'
|
||||
};
|
||||
|
||||
if (p.time) {
|
||||
header['Last-Modified'] = p.time;
|
||||
}
|
||||
|
||||
cmp = Util.strCmp(ext, '.appcache');
|
||||
if (!cmp && p.cache)
|
||||
header['Cache-Control'] = 'max-age=' + 31337 * 21;
|
||||
|
|
@ -239,10 +242,11 @@
|
|||
|
||||
if (lRet) {
|
||||
p = pParams;
|
||||
lGzip = isGZIP(p.request) && p.gzip;
|
||||
lGzip = p.isGzip || isGZIP(p.request) && p.gzip;
|
||||
|
||||
header = generateHeaders({
|
||||
name : p.name,
|
||||
time : p.time,
|
||||
cache : p.cache,
|
||||
gzip : lGzip,
|
||||
query : getQuery(p.request)
|
||||
|
|
@ -261,22 +265,37 @@
|
|||
* @param pGzip - данные сжаты gzip'ом
|
||||
*/
|
||||
function sendFile(params) {
|
||||
var isGzip,
|
||||
p = params,
|
||||
ret = checkParams(params);
|
||||
var isGzip, getTime,
|
||||
p = params,
|
||||
ret = checkParams(params);
|
||||
|
||||
if (ret) {
|
||||
isGzip = isGZIP(p.request) && p.gzip;
|
||||
|
||||
mainSetHeader(params);
|
||||
getTime = Util.bind(time.get, p.name, {
|
||||
str: true
|
||||
});
|
||||
|
||||
pipe.create({
|
||||
from : p.name,
|
||||
write : p.response,
|
||||
gzip : isGzip,
|
||||
callback: function(error) {
|
||||
if (error)
|
||||
sendError(params, error);
|
||||
getTime(function(error, time) {
|
||||
if (error) {
|
||||
sendError(params, error);
|
||||
} else {
|
||||
Util.copyObj(p, {
|
||||
isGzip : isGzip,
|
||||
time : time
|
||||
});
|
||||
|
||||
mainSetHeader(params);
|
||||
|
||||
pipe.create({
|
||||
from : p.name,
|
||||
write : p.response,
|
||||
gzip : isGzip,
|
||||
callback: function(error) {
|
||||
if (error)
|
||||
sendError(params, error);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue