Tag: unixsockets

Node.js:通过unix套接字发送GET请求

我是新的node.js。 我试图设置客户端服务器连接使用unix套接字,其中我的客户端请求将在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) } } }) 当我尝试与写入的服务器通信时,它显示HTTP error: 400 Bad Request: malformed Host header' 同样的作品: curl -X GET –unix-socket /tmp/static0.sock http://:/volumes/list 不知道我的请求有什么问题。 我们需要发送标题吗? 我期待JSON响应。