Skip to content

Commit

Permalink
do not require writeHead to be called
Browse files Browse the repository at this point in the history
  • Loading branch information
tjanczuk committed Jul 15, 2013
1 parent f94cb73 commit 3298829
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
2 changes: 2 additions & 0 deletions lib/Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ Server.prototype._on_new_request = function(requestContext) {
requestContext.requestRead = false;
requestContext.server = this;
requestContext.headers = {};
requestContext.statusCode = 200;
requestContext.reason = 'OK';
requestContext.socket = new Socket(requestContext);
requestContext.req = new ServerRequest(requestContext.socket);

Expand Down
3 changes: 0 additions & 3 deletions lib/Socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,6 @@ Socket.prototype._writeHead = function (statusCode, reasonPhrase, headers) {
};

Socket.prototype.write = function(chunk, encoding, isEnd) {
if (!this._requestContext.headers)
throw new Error('The writeHead method must be called before the write method.');

if (!this._requestContext.knownHeaders) {

// First call to write prepares the cached response headers
Expand Down
2 changes: 1 addition & 1 deletion samples/101_server.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// var http = require('http');
//var http = require('http');
var http = require('../lib/httpsys').http();

http.createServer(function (req, res) {
Expand Down

0 comments on commit 3298829

Please sign in to comment.