From 0638a3a3ab680b99c36cc09904d10bbfd76c65ba Mon Sep 17 00:00:00 2001 From: Ryan Date: Sun, 9 Aug 2009 19:16:25 +0200 Subject: [PATCH] Add IncomingMessage.prototype.pause() and resume(). --- src/http.js | 8 ++++++++ website/api.txt | 15 +++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/src/http.js b/src/http.js index 94430c1496..c0ea4b4aac 100644 --- a/src/http.js +++ b/src/http.js @@ -134,6 +134,14 @@ IncomingMessage.prototype.setBodyEncoding = function (enc) { this.connection.setEncoding(enc); }; +IncomingMessage.prototype.pause = function () { + this.connection.readPause(); +}; + +IncomingMessage.prototype.resume = function () { + this.connection.readResume(); +}; + function OutgoingMessage () { node.EventEmitter.call(this); diff --git a/website/api.txt b/website/api.txt index 29495164c9..91c1591f5b 100644 --- a/website/api.txt +++ b/website/api.txt @@ -706,6 +706,15 @@ The HTTP protocol version as a string. Read only. Examples: Set the encoding for the request body. Either +"utf8"+ or +"raw"+. Defaults to raw. + ++request.pause()+ :: +Pauses request from emitting events. Useful to throttle back an upload. + + ++request.resume()+ :: +Resumes a paused request. + + +request.connection+ :: The +node.http.Connection+ object. @@ -891,6 +900,12 @@ After emitted no other events will be emitted on the response. Set the encoding for the response body. Either +"utf8"+ or +"raw"+. Defaults to raw. ++response.pause()+ :: + Pauses response from emitting events. Useful to throttle back a download. + ++response.resume()+ :: + Resumes a paused response. + +response.client+ :: A reference to the +node.http.Client+ that this response belongs to.