forked from tjanczuk/httpsys
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServerResponse.js
More file actions
54 lines (42 loc) · 1.64 KB
/
Copy pathServerResponse.js
File metadata and controls
54 lines (42 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
var events = require('events')
, util = require('util');
function ServerResponse(socket) {
events.EventEmitter.call(this);
this._socket = socket;
this.sendDate = true;
var self = this;
this._socket.on('close', function (had_error) { self.emit('close', had_error); });
};
util.inherits(ServerResponse, events.EventEmitter);
ServerResponse.prototype.writeHead = function (statusCode, reasonPhrase, headers) {
this._socket._requestContext.responseStarted = true;
return this._socket._writeHead(statusCode, reasonPhrase, headers);
};
ServerResponse.prototype.destroy = function (error) {
return this._socket.destroy(error);
};
ServerResponse.prototype.write = function(chunk, encoding, isEnd) {
this._socket._requestContext.responseStarted = true;
return this._socket.write(chunk, encoding, isEnd);
};
ServerResponse.prototype.end = function (chunk, encoding) {
return this.write(chunk, encoding, true);
};
ServerResponse.prototype.writeContinue = function () {
throw new Error('The writeContinue method is not supported because 100 Continue '
+ ' responses are sent automatically by HTTP.SYS.');
};
ServerResponse.prototype.setHeader = function (name, value) {
return this._socket._setHeader(name, value);
};
ServerResponse.prototype.getHeader = function (name) {
return this._socket._getHeader(name);
};
ServerResponse.prototype.removeHeader = function (name) {
return this._socket._removeHeader(name);
};
ServerResponse.prototype.addTrailers = function () {
// TODO support for trailers
throw new Error('Support for trailers is not yet implemented.');
}
module.exports = ServerResponse;