Skip to content
Browse files

Fixed the bug web.use(web.compress()) caused

  • Loading branch information...
1 parent 1b96d2c commit f166f01994ffb0ef9944fbc020d5ff9031f0e44e @iwillwen committed Oct 4, 2012
Showing with 6 additions and 7 deletions.
  1. +6 −7 lib/response.js
View
13 lib/response.js
@@ -11,10 +11,8 @@ var mimes = require('./mimes').mimes;
var util = require('util');
var utils = require('./utils');
var dataStream = require('dataStream');
-var async = process.nextTick;
var httpStatus = require('./httpstatus').status;
var eventproxy = require('eventproxy').EventProxy;
-var pathmo = require('path');
var http = require('http');
// deafult cookie config
@@ -96,7 +94,7 @@ Response.prototype.send = function (data, _charset) {
// begin setting the stream pipelining
var last = this;
pipes.push(function () {
- return last.self;
+ return self.self;
});
for (var i = 0; i < pipes.length; i++) {
var newone = pipes[i]();
@@ -296,6 +294,7 @@ Response.prototype.render = function () {
view[key] = dynamicView[key];
if (view.local) {
layout_view[key] = dynamicView[key];
+ view.local[key] = dynamicView[key];
}
}
for (var key in _view) {
@@ -307,7 +306,7 @@ Response.prototype.render = function () {
if (view.root) layout_view.root = view.root;
view = view.local;
view.filename = root + name + '.' + ext;
- layout_view.filename = root + name + '.' + ext;
+ layout_view.filename = root + 'layout.' + ext;
}
@@ -437,11 +436,11 @@ Response.prototype.sendJSON = function (data) {
this.emit('sendJSON', data);
switch (typeof data) {
case "string":
- this.send(data, 'application/json');
+ this.send(data, 'application/json; charset=UTF-8');
break;
case "array":
case "object":
- this.send(JSON.stringify(data), 'application/json');
+ this.send(JSON.stringify(data), 'application/json; charset=UTF-8');
break;
}
return this;
@@ -528,7 +527,7 @@ function sendfile (_fileName, res, found, _charset) {
fs.stat(_fileName, function (err, stats) {
if (err) return res.sendError(404);
var size = stats.size;
- var format = pathmo.extname(_fileName);
+ var format = require('path').extname(_fileName);
var lastModified = stats.mtime.toUTCString();
res.last = lastModified;
format = format ? format.slice(1) : 'unknown';

0 comments on commit f166f01

Please sign in to comment.
Something went wrong with that request. Please try again.