nodejs / nodejs/node

Passing a URL instance with a CONNECT method results in an invalid path

未关闭
#34,347 11 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

http
主要语言
JavaScript
星标
122k
派生
37.4k
平均合并
4 天 3 小时
30 天内合并 PR
272

描述

  • 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

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先使用 http.request、一个 URL 实例和 CONNECT 方法运行提供的 Node.js 重现。跟踪 HTTP 客户端的 URL 处理,并检查现有的 CONNECT 请求测试。当服务器接收到 example.com 而不是 /example.com,并且有一个覆盖该行为的回归测试时,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
javascript, nodejs
领域
networking
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
冷清
描述清晰度
描述清楚
新手友好度
70/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。