You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
370 B

4 years ago
  1. var duplexify = require('duplexify')
  2. var http = require('http')
  3. var request = function(opts) {
  4. var req = http.request(opts)
  5. var dup = duplexify()
  6. dup.setWritable(req)
  7. req.on('response', function(res) {
  8. dup.setReadable(res)
  9. })
  10. return dup
  11. }
  12. var req = request({
  13. method: 'GET',
  14. host: 'www.google.com',
  15. port: 80
  16. })
  17. req.end()
  18. req.pipe(process.stdout)