Passing a URL instance with a CONNECT method results in an invalid path
Aperta
Nessuno ha ancora preso questa issue.
http
- Lingua principale
- JavaScript
- Stelle
- 122k
- Fork
- 37.4k
- Merge medio
- 4g 3h
- PR unite (30g)
- 272
Descrizione
- Version: >=v10.21.0
- Platform: Linux solus 5.6.18-156.current #1 SMP PREEMPT Sun Jun 21 07:16:38 UTC 2020 x86_64 GNU/Linux
- Subsystem: http, https, url
What steps will reproduce the bug?
const http = require('http');
const server = http.createServer();
server.on('connect', (request, stream) => {
console.log(request.url);
stream.end('HTTP/1.1 501 Not Implemented\r\n\r\n');
});
server.listen(error => {
if (error) {
throw error;
}
const url = new URL(`http://localhost:${server.address().port}/example.com`);
const request = http.request(url, {method: 'CONNECT'}).end();
request.once('connect', response => {
response.destroy();
server.close();
});
});
How often does it reproduce? Is there a required condition?
Always.
What is the expected behavior?
example.com
What do you see instead?
/example.com
Additional information
There is a workaround for this:
-const request = http.request(url, {method: 'CONNECT'}).end();
+const request = http.request({
+ hostname: url.hostname,
+ port: url.port,
+ path: 'example.com',
+ method: 'CONNECT'
+}).end();
/cc @yovanoc
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia eseguendo la riproduzione Node.js fornita con http.request, un'istanza di URL e il metodo CONNECT. Segui la gestione degli URL da parte del client HTTP e ispeziona i test esistenti per le richieste CONNECT. Il lavoro è completo quando il server riceve example.com invece di /example.com, con un test di regressione che copra questo comportamento.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- javascript, nodejs
- Ambito
- networking
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Tranquilla
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 70/100