question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Q: Can you write more data to client http connection?

See original GitHub issue

I would like to write data back to client after a push event. I could not find a clear way to do this:

repos.on('push', (push) => {
  push.accept();
  push.client.write('---> Building Application.')
  // ...
  push.client.write('Done.')
})

Think of this like git push heroku master for deploying code. Heroku outputs the build logs during the push command.

$ git push foobar master

Counting objects: 3, done.
Writing objects: 100% (3/3), 633 bytes | 633.00 KiB/s, done.
Total 3 (delta 0), reused 3 (delta 0)
To http://localhost:7005/beep
 * [new branch]      master -> master

---> Building Application.
Done.

Thanks 🙏

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:12 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
gabrielcsapocommented, Nov 27, 2018

after months of this being an issue https://github.com/gabrielcsapo/node-git-server/releases/tag/0.5.0 we have landed 🚀

1reaction
xanfcommented, Nov 26, 2018

For those, who are looking for solution like me, here comes a code to get you started:

const pack = s => {
  const n = (4 + s.length).toString(16);
  return Array(4 - n.length + 1).join('0') + n + s;
};

repos.on('push', push => {
  push.on('response', str => {
    push.once('exit', () => {
      const SIDEBAND = String.fromCharCode(2); // PROGRESS
      const message = `${SIDEBAND}hello long long long\n`;
      const formattedMessage = Buffer.from(pack(message));
      str.queue(formattedMessage);
      str.queue(Buffer.from('0000'));
      str.queue(null);
    });
  });

  console.log(`push ${push.repo}/${push.commit} (${push.branch})`);
  push.accept();
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

HTTP/1.1: Connections
- HTTP requests and responses can be pipelined on a connection. Pipelining allows a client to make multiple requests without waiting for each...
Read more >
How do multiple clients connect simultaneously to one port ...
First understand that for a single server process that is listening to same port, there could be more than one sockets (may be...
Read more >
How to Use an API: Just the Basics 2022 | TechnologyAdvice
Ever wonder what an API is or how to use one? APIs allow one program to request data from another. Learn more about...
Read more >
HTTP Client | WebStorm Documentation - JetBrains
With the HTTP Client plugin, you can create, edit, and execute HTTP requests directly in the WebStorm code editor.
Read more >
Everything you need to know to Build a simple HTTP server ...
Technically, HTTPS is same as HTTP with more security. ... Before a client can connect to a server, the server should have a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found