Skip to content

Commit

Permalink
wrapping writeHead override in else block
Browse files Browse the repository at this point in the history
  • Loading branch information
steelThread committed Oct 1, 2010
1 parent 1ada88b commit 00e0cbd
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions lib/connect-jsonp.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,33 +55,33 @@ module.exports = function jsonp() {
return;

} else {
var context = {
writeHead : res.writeHead,
write : res.write,
end : res.end
};
var context = {
writeHead : res.writeHead,
write : res.write,
end : res.end
};

res.writeHead = function(statusCode, headers) {
if (statusCode === 200) {
var body = '';
res.write = function(chunk, encoding) {
body += chunk
}
res.writeHead = function(statusCode, headers) {
if (statusCode === 200) {
var body = '';
res.write = function(chunk, encoding) {
body += chunk
}

res.end = function(chunk, encoding) {
if (chunk) body += chunk;
body = url.query.callback + '(' + body + ')';
headers['Content-Type'] = APP_JS_CONTENT_TYPE;
headers['Content-Length'] = body.length;
previous(statusCode, headers, res, context, body, encoding);
};
res.end = function(chunk, encoding) {
if (chunk) body += chunk;
body = url.query.callback + '(' + body + ')';
headers['Content-Type'] = APP_JS_CONTENT_TYPE;
headers['Content-Length'] = body.length;
previous(statusCode, headers, res, context, body, encoding);
};

} else {
previous(statusCode, headers, res, context);
}
};
} else {
previous(statusCode, headers, res, context);
}
};

next();
}
next();
}
};
};

0 comments on commit 00e0cbd

Please sign in to comment.