Closed Rumatoid closed 2 months ago
it returns 'Not Found'
Hello, I just tested this and it works properly.
Just run the code you provided locally and then run the following code against it:
const { URL } = require('url');
const http = require('http');
const host = 'example.com:80';
const url = new URL(`http://${host}/`);
const getMessage = (socket) => {
const request = http.request(url, {
createConnection: () => socket,
}, response => {
const chunks = [];
response.on('data', (chunk) => {
chunks.push(chunk);
});
response.once('end', () => {
console.log(Buffer.concat(chunks).toString());
});
});
request.once('error', (error) => {
console.error('tunnel error', error);
});
request.end();
};
const request = http.request('http://localhost:8000', {
method: 'CONNECT',
headers: {
host,
},
path: host,
});
request.once('connect', (response, socket, head) => {
getMessage(socket);
});
request.once('error', (error) => {
console.error('connect error', error);
});
request.end();
You should see
Hello from a custom server!
From readme
Doesnt do anything