Advertisement
Guest User

Untitled

a guest
Jan 8th, 2014
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.25 KB | None | 0 0
  1. From bdd1406eec74f441404811c0eca8605170e52573 Mon Sep 17 00:00:00 2001
  2. From: Max Ogden <max@maxogden.com>
  3. Date: Wed, 8 Jan 2014 14:25:29 -0800
  4. Subject: [PATCH] add done callback and document the response event
  5.  
  6. ---
  7. lib/service.js | 7 ++++++-
  8. readme.markdown | 17 +++++++++++++++++
  9. 2 files changed, 23 insertions(+), 1 deletion(-)
  10.  
  11. diff --git a/lib/service.js b/lib/service.js
  12. index db303ae..d4b8f88 100644
  13. --- a/lib/service.js
  14. +++ b/lib/service.js
  15. @@ -96,8 +96,13 @@ function Service (opts, req, res) {
  16. return;
  17. this.queue(null);
  18. })
  19. +
  20. + function endResponse() {
  21. + res.queue(new Buffer('0000'));
  22. + res.queue(null);
  23. + }
  24.  
  25. - self.emit('response', respStream);
  26. + self.emit('response', respStream, endResponse);
  27. ps.stdout.pipe(respStream).pipe(res);
  28.  
  29. buffered.pipe(ps.stdin);
  30. diff --git a/readme.markdown b/readme.markdown
  31. index 35a1a22..68f2b26 100644
  32. --- a/readme.markdown
  33. +++ b/readme.markdown
  34. @@ -184,6 +184,23 @@ no listeners, `head.accept()` is called automatically.
  35.  
  36. * head.repo
  37.  
  38. +## push.on('response', function(response, done) { ... })
  39. +
  40. +Emitted when pushover creates a resposne stream that will be sent to the git client on the other end.
  41. +
  42. +This should really only be used if you want to send verbose or error messages to the remote git client.
  43. +
  44. +`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.
  45. +
  46. +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:
  47. +
  48. +```js
  49. +response.queue(new Buffer('0000'))
  50. +response.queue(null)
  51. +```
  52. +
  53. +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.
  54. +
  55. # http duplex objects
  56.  
  57. The arguments to each of the events `'push'`, `'fetch'`, `'info'`, and `'head'`
  58. --
  59. 1.8.3.4 (Apple Git-47)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement