HTTP的GET消息格式修改
- Dominant language
- C++
- Stars
- 2.1k
- Forks
- 649
- PR merge metrics
- No merged PRs in 30d
Description
在使用sofa-pbrpc时,经常会遇到get消息中参数很少的情况,比如:http://XXX/ip2location.parse?request={"ip":"124.117.112.2"},但是常规来说大家倾向于使用http://XXX/ip2location.parse?ip=124.117.112.2的方式,所以需要对sofa-pbrpc源码进行修改:
修改sofa-pbrpc/src/sofa/pbrpc/http_rpc_request.cc:109文件:
json_str = _query_params["request"];
更新为:
if(_query_params.find("request") != _query_params.end())
{
json_str = _query_params["request"];
}
if (json_str == "" && _query_params.size() != 0)
{
bool add = false;
json_str = "{";
for (std::map::iterator it = _query_params.begin(); it != _query_params.end(); ++it)
{
if(add)
{
json_str += ",";
}
else
{
add = true;
}
json_str += "\"";
json_str += it->first;
json_str += "\":\"";
json_str += it->second;
json_str += "\"";
}
json_str += "}";
}
代码不是很规范,还请团队帮忙修改。
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in sofa-pbrpc/src/sofa/pbrpc/http_rpc_request.cc at line 109, where the request query is read from the request parameter. Review how query parameters are represented there and support the documented direct-parameter GET form while preserving the existing request form. Done means both URL styles produce the intended request data.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 50/100