mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 18:55:26 +00:00
refactor(main) sendFile
This commit is contained in:
parent
a0bb32ae66
commit
0fde796de8
1 changed files with 5 additions and 10 deletions
|
|
@ -260,20 +260,18 @@
|
|||
*
|
||||
*/
|
||||
function sendFile(params) {
|
||||
var isGzip,
|
||||
p = params,
|
||||
var p = params,
|
||||
ret = checkParams(params);
|
||||
|
||||
if (ret) {
|
||||
isGzip = isGZIP(p.request) && p.gzip;
|
||||
|
||||
if (ret)
|
||||
fs.lstat(p.name, function(error, stat) {
|
||||
var time, length, range,
|
||||
var time, length, range, isGzip,
|
||||
options = {};
|
||||
|
||||
if (error) {
|
||||
sendError(params, error);
|
||||
} else {
|
||||
isGzip = isGZIP(p.request) && p.gzip;
|
||||
time = stat.mtime,
|
||||
length = stat.size,
|
||||
range = getRange(p.request, length);
|
||||
|
|
@ -291,7 +289,7 @@
|
|||
mainSetHeader(params);
|
||||
|
||||
options = {
|
||||
gzip : isGzip && !range,
|
||||
gzip : isGzip,
|
||||
range : range
|
||||
};
|
||||
|
||||
|
|
@ -301,9 +299,6 @@
|
|||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue