[英]Cant get path to a string using Poco
I'm trying to put the path in a string, but it always empty: 我正在尝试将路径放在字符串中,但始终为空:
Poco::URI uri("http://10.10.10.10:3535");
std::string path(uri.getPathAndQuery());
This string part never receive anything and stays empty.. The code snippet is taking from an example https://gist.github.com/FatalCatharsis/749d93b4592e7d59d91a 此字符串部分永远不会接收任何内容,并且保持为空。.代码段摘自示例https://gist.github.com/FatalCatharsis/749d93b4592e7d59d91a
In your URI the Path and Query are empty, so it is correct that you see an empty string. 在URI中,“路径”和“查询”为空,因此看到一个空字符串是正确的。 Your URI only has a Scheme, Host and Port.
您的URI只有一个Scheme,Host和Port。
Here is a diagram of the URI format from Wikipedia: 这是Wikipedia的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
does not have any path or query in the string, that is why it is empty. http://10.10.10.10:3535
在字符串中没有任何路径或查询,这就是为什么它为空的原因。 Here is you can separate URI : 这是您可以分开的URI:
scheme:[//[user:password@]host[:port]][/]path[?query][#fragment]
eg. http:://192.168.11.2:3000/user?action=edit#basic
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.