Skip to content
This repository has been archived by the owner on Jun 23, 2022. It is now read-only.

fix(http): fix parse path from message #663

Merged
merged 4 commits into from
Nov 16, 2020

Conversation

hycdong
Copy link
Contributor

@hycdong hycdong commented Nov 10, 2020

In #594, it simplified http path, but it left a problem. For example:
The http request sent to meta server to list all apps is like ip:port/meta/apps, http server will add a tuple like <'meta/apps', 'apps_handler'>, when server receives a http request, it will parse path from request, and find the handler by path.
In current implementation, the registered path is like meta/apps, and the path parsed from request is /meta/apps, as a result, the handler can not be found.
This pr fix this problem, the path parsed from request will be meta/apps as the implementation before #594.

@hycdong hycdong added the type/bug-fix This PR fixes a bug. label Nov 10, 2020
@hycdong hycdong marked this pull request as ready for review November 10, 2020 05:37
src/http/http_server.cpp Outdated Show resolved Hide resolved
real_args.emplace_back(std::move(arg));
}
}
if (real_args.size() == 0) {
Copy link
Contributor

@levy5307 levy5307 Nov 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

 std::string path;
for (const auto &real_arg: real_rags) {
            path += real_arg;
            path += '/';
}

if (!path.empty()) {
    ret.path = std::move(path.substr(value.size() - 1));
}

@neverchanje neverchanje merged commit 82e10a2 into XiaoMi:master Nov 16, 2020
@hycdong hycdong deleted the fix_http_bug_2 branch November 27, 2020 01:43
hycdong added a commit that referenced this pull request Dec 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type/bug-fix This PR fixes a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants