@@ -111,7 +111,7 @@ function OutgoingMessage () {
111111sys . inherits ( OutgoingMessage , events . EventEmitter ) ;
112112exports . OutgoingMessage = OutgoingMessage ;
113113
114- OutgoingMessage . prototype . send = function ( data , encoding ) {
114+ OutgoingMessage . prototype . _send = function ( data , encoding ) {
115115 var length = this . output . length ;
116116
117117 if ( length === 0 ) {
@@ -139,7 +139,7 @@ OutgoingMessage.prototype.send = function (data, encoding) {
139139 this . outputEncodings . push ( encoding ) ;
140140} ;
141141
142- OutgoingMessage . prototype . sendHeaderLines = function ( first_line , headers ) {
142+ OutgoingMessage . prototype . _sendHeaderLines = function ( first_line , headers ) {
143143 var sentConnectionHeader = false ;
144144 var sendContentLengthHeader = false ;
145145 var sendTransferEncodingHeader = false ;
@@ -197,19 +197,19 @@ OutgoingMessage.prototype.sendHeaderLines = function (first_line, headers) {
197197
198198 messageHeader += CRLF ;
199199
200- this . send ( messageHeader ) ;
200+ this . _send ( messageHeader ) ;
201201 // wait until the first body chunk, or finish(), is sent to flush.
202202} ;
203203
204- OutgoingMessage . prototype . sendBody = function ( chunk , encoding ) {
204+ OutgoingMessage . prototype . write = function ( chunk , encoding ) {
205205 encoding = encoding || "ascii" ;
206206 if ( this . chunkEncoding ) {
207- this . send ( process . _byteLength ( chunk , encoding ) . toString ( 16 ) ) ;
208- this . send ( CRLF ) ;
209- this . send ( chunk , encoding ) ;
210- this . send ( CRLF ) ;
207+ this . _send ( process . _byteLength ( chunk , encoding ) . toString ( 16 ) ) ;
208+ this . _send ( CRLF ) ;
209+ this . _send ( chunk , encoding ) ;
210+ this . _send ( CRLF ) ;
211211 } else {
212- this . send ( chunk , encoding ) ;
212+ this . _send ( chunk , encoding ) ;
213213 }
214214
215215 if ( this . flushing ) {
@@ -219,12 +219,17 @@ OutgoingMessage.prototype.sendBody = function (chunk, encoding) {
219219 }
220220} ;
221221
222+ OutgoingMessage . prototype . sendBody = function ( ) {
223+ throw new Error ( 'sendBody() renamed to write()' ) ;
224+ } ;
225+
226+
222227OutgoingMessage . prototype . flush = function ( ) {
223228 this . emit ( "flush" ) ;
224229} ;
225230
226- OutgoingMessage . prototype . finish = function ( ) {
227- if ( this . chunkEncoding ) this . send ( "0\r\n\r\n" ) ; // last chunk
231+ OutgoingMessage . prototype . close = function ( ) {
232+ if ( this . chunkEncoding ) this . _send ( "0\r\n\r\n" ) ; // last chunk
228233 this . finished = true ;
229234 this . flush ( ) ;
230235} ;
@@ -241,10 +246,16 @@ function ServerResponse (req) {
241246sys . inherits ( ServerResponse , OutgoingMessage ) ;
242247exports . ServerResponse = ServerResponse ;
243248
244- ServerResponse . prototype . sendHeader = function ( statusCode , headers ) {
249+ ServerResponse . prototype . writeHead = function ( statusCode , headers ) {
245250 var reason = STATUS_CODES [ statusCode ] || "unknown" ;
246251 var status_line = "HTTP/1.1 " + statusCode . toString ( ) + " " + reason + CRLF ;
247- this . sendHeaderLines ( status_line , headers ) ;
252+ this . _sendHeaderLines ( status_line , headers ) ;
253+ } ;
254+
255+ ServerResponse . prototype . writeHeader = ServerResponse . prototype . writeHead ;
256+
257+ ServerResponse . prototype . sendHeader = function ( ) {
258+ throw new Error ( 'sendHeader renamed to writeHead()' ) ;
248259} ;
249260
250261
@@ -259,7 +270,7 @@ function ClientRequest (method, url, headers) {
259270 }
260271 this . closeOnFinish = true ;
261272
262- this . sendHeaderLines ( method + " " + url + " HTTP/1.1\r\n" , headers ) ;
273+ this . _sendHeaderLines ( method + " " + url + " HTTP/1.1\r\n" , headers ) ;
263274}
264275sys . inherits ( ClientRequest , OutgoingMessage ) ;
265276exports . ClientRequest = ClientRequest ;
@@ -282,7 +293,7 @@ function flushMessageQueue (socket, queue) {
282293 var data = message . output . shift ( ) ;
283294 var encoding = message . outputEncodings . shift ( ) ;
284295
285- socket . send ( data , encoding ) ;
296+ socket . write ( data , encoding ) ;
286297 }
287298
288299 if ( ! message . finished ) break ;
0 commit comments