mirror of
https://github.com/JasonYANG170/IOTConnect-Web.git
synced 2024-11-23 12:16:29 +00:00
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)
|