Skip to content
This repository has been archived by the owner on Jun 2, 2021. It is now read-only.

Commit

Permalink
improve code
Browse files Browse the repository at this point in the history
  • Loading branch information
zensh committed Jan 15, 2016
1 parent fb79e58 commit 9ccb2e2
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
All notable changes to this project will be documented in this file starting from version **v0.10.0**.
This project adheres to [Semantic Versioning](http://semver.org/).

## [1.3.2] - 2015-01-15

### change

- Updated dependencies, improve code.

## [1.3.1] - 2015-01-02

### fixed
Expand Down
13 changes: 8 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@
var util = require('util')
var http = require('http')
var Stream = require('stream')

var thunks = require('thunks')
var statuses = require('statuses')
var Cookies = require('cookies')
var accepts = require('accepts')
var isJSON = require('koa-is-json')
var Cookies = require('cookies')
var statuses = require('statuses')
var onFinished = require('on-finished')
var EventEmitter = require('events').EventEmitter

Expand Down Expand Up @@ -309,7 +307,7 @@ function onResError (err) {
var msg = err.expose ? err.message : statuses[this.status]

// hide server directory for error response
this.body = msg.replace(pwdReg, '[Server Directory]')
this.body = msg.replace(pwdReg, '[application]')
respond.call(this)
return err
}
Expand Down Expand Up @@ -356,6 +354,11 @@ function endRespond (ctx) {
ctx.emit('end')
}

function isJSON (body) {
return body && typeof body !== 'string' && !Buffer.isBuffer(body) &&
!(body instanceof Stream)
}

if (process.env.NODE_ENV === 'test') {
Toa.createContext = function () {
return createContext.apply(null, arguments)
Expand Down
6 changes: 3 additions & 3 deletions lib/response.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,9 @@ module.exports = {
// no content
if (val == null) {
if (!statuses.empty[this.status]) this.status = 204
this.res.removeHeader('content-type')
this.res.removeHeader('content-length')
this.res.removeHeader('transfer-encoding')
this.remove('content-type')
this.remove('content-length')
this.remove('transfer-encoding')
return
}

Expand Down
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"authors": [
"Yan Qing <admin@zensh.com>"
],
"version": "1.3.1",
"version": "1.3.2",
"main": "index.js",
"license": "MIT",
"repository": {
Expand Down Expand Up @@ -38,12 +38,11 @@
"fresh": "~0.3.0",
"http-assert": "~1.1.1",
"http-errors": "~1.3.1",
"koa-is-json": "~1.0.0",
"mime-types": "~2.1.8",
"mime-types": "~2.1.9",
"on-finished": "~2.3.0",
"parseurl": "~1.3.0",
"statuses": "~1.2.1",
"thunks": "^4.1.1",
"thunks": "^4.1.2",
"type-is": "~1.6.10",
"vary": "~1.1.0"
},
Expand Down

0 comments on commit 9ccb2e2

Please sign in to comment.