mirror of
https://github.com/snail007/goproxy.git
synced 2026-04-27 00:15:51 +03:00
[GH-ISSUE #23] HTTP一级代理,浏览器重用TCP链接请求其他站点 导致404 Error #16
Labels
No labels
TODO
bug
duplicate
enhancement
good first issue
help wanted
helpful
invalid
need-confirm
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/goproxy#16
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @comphilip on GitHub (Jan 23, 2018).
Original GitHub issue: https://github.com/snail007/goproxy/issues/23
使用HTTP一级代理模式,浏览器会重用连接到HTTP代理的TCP连接。
例如:
用户打开 http://www.xinhuanet.com/,浏览器创建TCP到goproxy,发送HTTP代理
请求,goproxy正确返回http://www.xinhuanet.com/的页面
用户在地址栏输入http://www.people.com.cn/, 浏览器重用原先的TCP链接,发送HTTP代理
请求,goproxy 没有留意域名已经改变,仍然向www.xinhuanet.com, 结果浏览器仍然显示 www.xinhuanet.com的主页
如果用户在地址栏输入网站二级页面,则大部分情况下返回404 Error。
@snail007 commented on GitHub (Jan 23, 2018):
你这是乱用http代理协议,http代理协议规定,只会在请求方法后面的完整url里面寻找需要连接的host,而不是头部的host字段。
@comphilip commented on GitHub (Jan 23, 2018):
何来乱用之说?
代理服务器是通过
./proxy http -t tcp -p "0.0.0.0:8080"我在firefox配置使用HTTP代理,然后发现这个现象。
我的使用场景应该是最普通的一种
@snail007 commented on GitHub (Jan 24, 2018):
请参考这个文章,http://www.what21.com/sys/view/service_server-service_1472192725537.html ,代理协议规定请求方法后面必须是完整的url,实现方应该去取url里的host去连接目标,而不是http协议头部里面的 HOST字段,如果你发现的没改变是指HOST字段变化,这本来就不是http协议规定的部分,如果是这种现象那就是代理客户端工具没有正确的使用http代理协议.
GET http://www.xinhuanet.com/ HTTP1.1
Host: www.people.com.cn
请求,这种现象本来就不对吧,你浏览器里面请求www.xinhuanet.com,http头部HOST应该是:www.xinhuanet.com,HOST怎么变成www.people.com.cn了?,这明显是客户端的问题.
@comphilip commented on GitHub (Jan 24, 2018):
实在很抱歉,应该是我编辑错了,上面的请求内容是我手动编辑的(我从技术角度说明Firefox发的请求是这样的),copy 之后没有改全,已更正。
我使用Firefox 57。