我是node.js的新手.我正在尝试使用unix socket设置客户端服务器连接,其中我的客户端请求将在node.js中,而后台运行的服务器将在其中.
客户端代码:
var request = require('request');
request('http://unix:/tmp/static0.sock:/volumes/list', function (error, response, body) {
if (!error && response.statusCode == 200) {
console.log(body)
} else {
console.log("In else part of the receiver" + response.statusCode + body)
}
}
})
Run Code Online (Sandbox Code Playgroud)
当我尝试与写入的服务器进行通信时,它显示了 HTTP error: 400 Bad Request: malformed Host header'
同样适用于:
curl -X GET --unix-socket /tmp/static0.sock http://:/volumes/list
Run Code Online (Sandbox Code Playgroud)
不确定我的请求有什么问题.我们需要发送标题吗?我期待JSON的回应.