Open loynoir opened 1 year ago
void http.request(
'http://localhost/version',
{
socketPath: '/var/run/docker.sock',
},
(res) => res.on('data', (c) => console.log('' + c)),
).end()
$ node
> void http.request('http://localhost/version', {socketPath: '/var/run/docker.sock'}, (res)=>res.on('data',c=>console.log(''+c))).end()
// {"Platform": ...
$ deno
> import http from 'node:http'
> void http.request('http://localhost/version', {socketPath: '/var/run/docker.sock'}, (res)=>res.on('data',c=>console.log(''+c))).end()
// nothing
@kt3k
https://github.com/denoland/deno/issues/8821#issuecomment-1408439707
https://deno.land/x/socket_fetch@v0.1/mod.ts
Maybe can merge that library into node/http.ts
logic?
https://deno.land/x/socket_fetch@v0.1/mod.ts
Maybe can merge that library into
node/http.ts
logic?
Unfortunately my socket_fetch library is incomplete :( It can only perform GET requests and is not optimized. I use it to query specific things but it's not in a shape to be dropped into npm libraries I think.
Ideally Deno ships some sort of Unix socket fetch client instead :)
Workaround
import { fetch, Agent } from 'undici'
const resp = await fetch('http://localhost/version', {
dispatcher: new Agent({
connect: {
socketPath: '/var/run/docker.sock'
}
})
})
console.log(await resp.text())
$ deno run --unstable -A ./reproduce.mjs
{"Platform":...
Describe the bug
Steps to Reproduce
Expected behavior
Environment