Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http url中含有‘#’的处理问题 #440

Closed
levy5307 opened this issue Dec 10, 2019 · 3 comments
Closed

http url中含有‘#’的处理问题 #440

levy5307 opened this issue Dec 10, 2019 · 3 comments

Comments

@levy5307
Copy link
Contributor

levy5307 commented Dec 10, 2019

在http请求中,'#'之后的部分叫做锚部分,该部分代表网页中的一个位置,用于浏览器读取这个url后,自动滚动到锚部分指定的区域。

由于锚部分是用来指导浏览器动作的,对服务器完全无用,所以HTTP请求中不会包含锚部分,也就是说,会将其截断、不发送给服务器。

目前我们有一个http接口,用于获取perf counter信息,例如:
http://127.0.0.1:34101/perfCounter?name=collector*app.pegasus*app.stat.read_qps#_all_用于获取名字为 collector*app.pegasus*app.stat.read_qps#_all_的perf counter信息,但是由于该名字中包含了‘#’,所以会将#_all_这部分截断,服务器获取到的请求就变成了http://127.0.0.1:34101/perfCounter?name=collector*app.pegasus*app.stat.read_qps,导致无法获取正确的perf counter信息。

目前我想到的办法是:
1.对用户端发出的请求和服务端收到的请求添加编解码,对这种特殊字符进行转义。
2.实现http_message_parser中对header部分的解析,将name={perf_counter_name}放到header部分中

1是比较常规的做法,业内对于传递特殊字符都需要编解码。2这里感觉也比较有必要,因为目前我们的http实现不健全,对于header和body部分都没有实现读取

@acelyc111
Copy link
Member

acelyc111 commented Dec 12, 2019

name=collector*app.pegasus*app.stat.read_qps#_all_
其实根本原因是我们的perf counter名字太诡异了,包含各种符号,用户是难以记忆的,后面的思路应该是怎么去优化名字的规则

@levy5307
Copy link
Contributor Author

name=collector*app.pegasus*app.stat.read_qps#_all_
其实根本原因是我们的perf counter名字太诡异了,包含各种符号,用户是难以记忆的,后面的思路应该是怎么去优化名字的规则

名字诡异确实是一方面,但是uri编解码也是必要的

@neverchanje
Copy link
Contributor

This problem was solved by XiaoMi/rdsn#357, reopen it when there is futher issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants