Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

manifest concat line index bugfix. reduce request timeout from 2m to …

…25s.
  • Loading branch information...
commit ed913b0195b2f6b194404c48fbc818ef05cff03d 1 parent 1f05e47
@jairajs89 authored
Showing with 15 additions and 4 deletions.
  1. +2 −2 package.json
  2. +13 −2 zerver.js
View
4 package.json
@@ -2,14 +2,14 @@
"author": "Jairaj Sethi <j@jairaj.org> (http://jairaj.org/)",
"name": "zerver",
"description": "client-integrated webapp server",
- "version": "0.6.12",
+ "version": "0.6.13",
"repository": {
"type": "git",
"url": "git://github.com/jairajs89/zerver.git"
},
"main": "nodeclient.js",
"engines": {
- "node": ">=0.8.0"
+ "node": "0.8.x"
},
"dependencies": {
"mime" : "1.2.7" ,
View
15 zerver.js
@@ -27,6 +27,7 @@ var ROOT_DIR = process.cwd(),
CONCAT_MATCH = /\<\!\-\-\s*zerver\:(\S+)\s*\-\-\>((\s|\S)*?)\<\!\-\-\s*\/zerver\s*\-\-\>/g,
SCRIPT_MATCH = /\<script(?:\s+\w+\=[\'\"][^\>]+[\'\"])*\s+src\=[\'\"]\s*([^\>]+)\s*[\'\"](?:\s+\w+\=[\'\"][^\>]+[\'\"])*\>\<\/script\>/g,
STYLES_MATCH = /\<link(?:\s+\w+\=[\'\"][^\>]+[\'\"])*\s+href\=[\'\"]\s*([^\>]+)\s*[\'\"](?:\s+\w+\=[\'\"][^\>]+[\'\"])*\/?\>/g,
+ REQUEST_TIMEOUT = 25 * 1000,
CONCAT_FILES = false,
GZIP_ENABLED = false,
COMPILATION_ENABLED = false,
@@ -246,9 +247,20 @@ function handleRequest (request, response) {
pathname = handler.pathname,
isApiCall = pathname.substr(0, API_URL_LENGTH + 2) === '/'+API_URL+'/';
+ setRequestTimeout(request, response);
+
tryResponseFromCache(handler, pathname, isApiCall, dynamicResponse);
}
+function setRequestTimeout (request, response) {
+ request.socket.removeAllListeners('timeout');
+ request.socket.setTimeout(REQUEST_TIMEOUT);
+ request.socket.once('timeout', function () {
+ console.log('zerver: request timeout, closing socket');
+ request.socket.destroy();
+ });
+}
+
function tryResponseFromCache (handler, pathname, isApiCall, fallback) {
if (!CACHE_ENABLED || isApiCall || !(pathname in memoryCache)) {
fallback(handler, pathname, isApiCall);
@@ -376,8 +388,7 @@ function prepareManifestConcatFiles (data, pathname, callback) {
i -= sectionLength;
l -= sectionLength;
- lines.splice(i, 1, concatFile);
- i++;
+ lines.splice(i+1, 0, concatFile);
l++;
concatCache[ relativePath(pathname, concatFile) ] = concatList;
Please sign in to comment.
Something went wrong with that request. Please try again.