How can I send back response headers with Node.js / Express?
问题 I'm using res.send and no matter what, it returns status of 200. I want to set that status to different numbers for different responses (Error, etc) This is using express 回答1: res.writeHead(200, {'Content-Type': 'text/event-stream'}); http://nodejs.org/docs/v0.4.12/api/http.html#response.writeHead 回答2: For adding response headers before send, you can use the setHeader method: response.setHeader('Content-Type', 'application/json') The status only by the status method: response.status(status