无法使用 Poco 获取字符串的路径

Cant get path to a string using Poco

我试图将路径放入字符串中,但它始终为空:

Poco::URI uri("http://10.10.10.10:3535");
std::string path(uri.getPathAndQuery());

这个字符串部分永远不会收到任何东西并且保持为空.. 代码片段取自示例 https://gist.github.com/FatalCatharsis/749d93b4592e7d59d91a

在你的 URI 中,Path 和 Query 是空的,所以你看到一个空字符串是正确的。您的 URI 只有方案、主机和端口。

这是来自维基百科的 URI 格式图:

                    authority               path
        ┌───────────────┴───────────────┐┌───┴────┐
  abc://username:password@example.com:123/path/data?key=value#fragid1
  └┬┘   └───────┬───────┘ └────┬────┘ └┬┘           └───┬───┘ └──┬──┘
scheme  user information     host     port            query   fragment

http://10.10.10.10:3535 字符串中没有任何路径或查询,这就是它为空的原因。 这是你可以分开的 URI :

scheme:[//[user:password@]host[:port]][/]path[?query][#fragment]
eg. http:://192.168.11.2:3000/user?action=edit#basic