Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- From bdd1406eec74f441404811c0eca8605170e52573 Mon Sep 17 00:00:00 2001
- From: Max Ogden <max@maxogden.com>
- Date: Wed, 8 Jan 2014 14:25:29 -0800
- Subject: [PATCH] add done callback and document the response event
- ---
- lib/service.js | 7 ++++++-
- readme.markdown | 17 +++++++++++++++++
- 2 files changed, 23 insertions(+), 1 deletion(-)
- diff --git a/lib/service.js b/lib/service.js
- index db303ae..d4b8f88 100644
- --- a/lib/service.js
- +++ b/lib/service.js
- @@ -96,8 +96,13 @@ function Service (opts, req, res) {
- return;
- this.queue(null);
- })
- +
- + function endResponse() {
- + res.queue(new Buffer('0000'));
- + res.queue(null);
- + }
- - self.emit('response', respStream);
- + self.emit('response', respStream, endResponse);
- ps.stdout.pipe(respStream).pipe(res);
- buffered.pipe(ps.stdin);
- diff --git a/readme.markdown b/readme.markdown
- index 35a1a22..68f2b26 100644
- --- a/readme.markdown
- +++ b/readme.markdown
- @@ -184,6 +184,23 @@ no listeners, `head.accept()` is called automatically.
- * head.repo
- +## push.on('response', function(response, done) { ... })
- +
- +Emitted when pushover creates a resposne stream that will be sent to the git client on the other end.
- +
- +This should really only be used if you want to send verbose or error messages to the remote git client.
- +
- +`response` is a writable stream that can accept buffers containing git packfile sidechannel transfer protocol encoded strings. `done` is a callback that must be called when you want to end the response.
- +
- +If you create a response listener then you must either call the `done` function or execute the following end sequence when you want to end the response:
- +
- +```js
- +response.queue(new Buffer('0000'))
- +response.queue(null)
- +```
- +
- +If you never use the response event then the above data will be sent by default. Binding a listener to the response event will prevent the end sequence those from being sent, so you must send them yourself after sending any other messages.
- +
- # http duplex objects
- The arguments to each of the events `'push'`, `'fetch'`, `'info'`, and `'head'`
- --
- 1.8.3.4 (Apple Git-47)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement