title: Nodejs send data in gzip using zlib
body: <p>I tried to send the text in gzip, but I don't know how. In the <a href="http://nodejs.org/docs/latest/api/zlib.html#zlib_examples" rel="noreferrer">examples</a> the code uses fs, but I don't want to send a text file, just a string.</p>
  
  <pre><code>const zlib = require('zlib');
  const http = require('http');
  
  http.createServer(function (req, res) {
      res.writeHead(200, {'Content-Type': 'text/html', 'Content-Encoding': 'gzip'});
  
      const text = "Hello World!";
      res.end(text);
  
  }).listen(80);
  </code></pre>