Passing a URL instance with a CONNECT method results in an invalid path
Đang mở
Chưa có ai nhận issue này.
http
- Ngôn ngữ chính
- JavaScript
- Star
- 122k
- Fork
- 37.3k
- Merge trung bình
- 4 ngày 2 giờ
- Pull request đã merge (30 ngày)
- 283
Mô tả
- 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
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu bằng cách chạy bản tái hiện Node.js được cung cấp bằng http.request, một phiên bản URL và phương thức CONNECT. Theo dõi cách ứng dụng HTTP client xử lý URL và kiểm tra các test hiện có cho các request CONNECT. Được xem là hoàn tất khi server nhận example.com thay vì /example.com, với một regression test bao quát hành vi này.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- javascript, nodejs
- Lĩnh vực
- networking
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Ít trao đổi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức phù hợp với người mới
- 70/100