Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Changed writeHead to individual setHeader calls to prevent issues wit…

…h current connect
  • Loading branch information...
commit 01df419feba0a41868fd539341e3aca234f7ba5b 1 parent 506a0c7
@maritz authored
Showing with 9 additions and 9 deletions.
  1. +4 −6 lib/connectMiddleware.js
  2. +5 −3 test/connectTests.js
View
10 lib/connectMiddleware.js
@@ -193,12 +193,10 @@ function connect(options){
return function (req, res, next) {
if (req.url === url) {
- var headers = {
- 'Content-Type': 'text/javascript',
- 'Content-Length': str.length,
- 'Cache-Control': 'public, max-age=' + maxAge
- };
- res.writeHead(200, headers);
+ res.statusCode = 200;
+ res.setHeader("Content-Type", "text/javascript");
+ res.setHeader("Content-Length", str.length);
+ res.setHeader("Cache-Control", "public, max-age=" + maxAge);
res.end(str);
} else {
next();
View
8 test/connectTests.js
@@ -71,9 +71,11 @@ var setup = function (t, expected, options, callback) {
var headersSet = false;
var namespace = (options && options.namespace) ? options.namespace : 'nohmValidations';
var dummyRes = {
- writeHead: function (status, headers) {
- t.ok(headers['Content-Length'] > 0, 'Header Content-Length was 0');
- length = headers['Content-Length'];
+ setHeader: function (name, value) {
+ if (name === "Content-Length") {
+ t.ok(value > 0, 'Header Content-Length was 0');
+ length = value;
+ }
headersSet = true;
},
end: function (str) {
Please sign in to comment.
Something went wrong with that request. Please try again.