-
-
Notifications
You must be signed in to change notification settings - Fork 969
Closed
Labels
Description
Describe the bug
- Node.js version: v10.16.3+ (at least)
- OS & version: Ubuntu 18.04 Linux 4.15.0-72-generic (probably any other OS)
- Got: v10.2.2
Actual behavior
Making a call via UNIX-socket results in not passing query string in URL. When making a call via normal TCP/IP port it works correctly. For example, for the code below we have received the output:
call to /tmp/app.sock, URL = /tmp/app.sock:/http?foo=bar
call to /tmp/app.sock, URL = /got # here should be a query-string
call to 3000, URL = /http?foo=bar
call to 3000, URL = /got?foo=bar
Expected behavior
Having query string in request in both cases. For example, for the code below it's expected the output:
call to /tmp/app.sock, URL = /tmp/app.sock:/http?foo=bar
call to /tmp/app.sock, URL = /tmp/app.sock:/got?foo=bar # here should be a query-string
call to 3000, URL = /http?foo=bar
call to 3000, URL = /got?foo=bar
or at least:
call to /tmp/app.sock, URL = /tmp/app.sock:/http?foo=bar
call to /tmp/app.sock, URL = /got?foo=bar # here should be a query-string
call to 3000, URL = /http?foo=bar
call to 3000, URL = /got?foo=bar
Code to reproduce
const fs = require('fs'),
http = require('http'),
got = require('got');
const port = 3000,
socket = '/tmp/app.sock',
search = '?foo=bar',
handler = (listen) => (req, res) => {
console.log(`call to ${listen}, URL = ${req.url}`);
res.statusCode = 204;
res.end();
},
cb = () => {};
//clean up and establish http server with unix-socket
if (fs.existsSync(socket)) fs.unlinkSync(socket);
http.createServer(handler(port)).listen(port);
http.createServer(handler(socket)).listen(socket);
//reference call with http via TCP/IP port
http.get(
new URL(`http://localhost:${port}/http${search}`),
{headers: {authorization: 'Basic aaa'}},
cb
);
//reference call with got via TCP/IP port
got
.get(`http://localhost:${port}/got${search}`, {headers: {authorization: 'Basic aaa'}})
.then(cb);
//reference call with http via unix-socket
http.get(
new URL(`http://unix:${socket}:/http${search}`),
{socketPath: '/tmp/app.sock', headers: {authorization: 'Basic aaa'}},
cb
);
//testing call with got via unix-socket
got
.get(`http://unix:${socket}:/got${search}`, {headers: {authorization: 'Basic aaa'}})
.then(cb);
Checklist
- I have read the documentation.
- I have tried my code with the latest version of Node.js and Got.
silverwind