Server::Request::path is split into path and query_string
This commit is contained in:
parent
2bb51a9fb0
commit
0c9cb000b4
3 changed files with 48 additions and 24 deletions
|
|
@ -57,6 +57,15 @@ int main() {
|
|||
<< content;
|
||||
};
|
||||
|
||||
server.resource["^/query_string$"]["GET"] = [](shared_ptr<HttpServer::Response> response, shared_ptr<HttpServer::Request> request) {
|
||||
assert(request->path == "/query_string");
|
||||
assert(request->query_string == "testing");
|
||||
auto queries = request->parse_query_string();
|
||||
auto it = queries.find("Testing");
|
||||
assert(it != queries.end() && it->first == "testing" && it->second == "");
|
||||
response->write(request->query_string);
|
||||
};
|
||||
|
||||
thread server_thread([&server]() {
|
||||
//Start server
|
||||
server.start();
|
||||
|
|
@ -163,6 +172,14 @@ int main() {
|
|||
assert(client.connections->size() == 1);
|
||||
assert(connection == client.connections->front().get());
|
||||
}
|
||||
|
||||
{
|
||||
stringstream output;
|
||||
auto r = client.request("GET", "/query_string?testing");
|
||||
assert(r->content.string() == "testing");
|
||||
assert(client.connections->size() == 1);
|
||||
assert(connection == client.connections->front().get());
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue