mirror of
https://github.com/nodejs/node.git
synced 2025-05-19 13:20:10 +00:00

PR-URL: https://github.com/nodejs/node/pull/20190 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
22 lines
370 B
JavaScript
22 lines
370 B
JavaScript
var duplexify = require('duplexify')
|
|
var http = require('http')
|
|
|
|
var request = function(opts) {
|
|
var req = http.request(opts)
|
|
var dup = duplexify()
|
|
dup.setWritable(req)
|
|
req.on('response', function(res) {
|
|
dup.setReadable(res)
|
|
})
|
|
return dup
|
|
}
|
|
|
|
var req = request({
|
|
method: 'GET',
|
|
host: 'www.google.com',
|
|
port: 80
|
|
})
|
|
|
|
req.end()
|
|
req.pipe(process.stdout)
|