我刚接触 node.js。我正在尝试使用Unix套接字建立客户端服务器连接,其中我的客户端请求将在node.js中进行,而在后台运行的服务器将是Go。
客户端代码:
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)
}
}
})
当我尝试与用Go编写的服务器通信时,它显示了“HTTP错误:400 Bad Request:malformed Host header”。
相同的内容可以正常工作:
curl -X GET --unix-socket /tmp/static0.sock http://:/volumes/list
我不确定我的请求出了什么问题。我们需要发送标题吗?我期望得到JSON响应。