Added arguments support to URL parser
This commit is contained in:
parent
40f1cec8f9
commit
35fbafc831
2 changed files with 8 additions and 1 deletions
|
@ -30,6 +30,11 @@ HTTP::URL::URL(const std::string & url){
|
||||||
size_t first_slash = url.find('/', proto_sep);
|
size_t first_slash = url.find('/', proto_sep);
|
||||||
if (first_slash != std::string::npos){
|
if (first_slash != std::string::npos){
|
||||||
path = url.substr(first_slash+1);
|
path = url.substr(first_slash+1);
|
||||||
|
size_t qmark = path.find('?');
|
||||||
|
if (qmark != std::string::npos){
|
||||||
|
args = path.substr(qmark+1);
|
||||||
|
path.erase(qmark);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//host and port are now definitely between proto_sep and first_slash
|
//host and port are now definitely between proto_sep and first_slash
|
||||||
//we check for [ at the start because we may have an IPv6 address as host
|
//we check for [ at the start because we may have an IPv6 address as host
|
||||||
|
@ -73,6 +78,7 @@ HTTP::URL::URL(const std::string & url){
|
||||||
EXTREME_MSG("URL protocol: %s", protocol.c_str());
|
EXTREME_MSG("URL protocol: %s", protocol.c_str());
|
||||||
EXTREME_MSG("URL port: %s", port.c_str());
|
EXTREME_MSG("URL port: %s", port.c_str());
|
||||||
EXTREME_MSG("URL path: %s", path.c_str());
|
EXTREME_MSG("URL path: %s", path.c_str());
|
||||||
|
EXTREME_MSG("URL args: %s", args.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
///Returns the port in numeric format
|
///Returns the port in numeric format
|
||||||
|
|
|
@ -77,7 +77,8 @@ namespace HTTP {
|
||||||
std::string host;///< Hostname or IP address of URL
|
std::string host;///< Hostname or IP address of URL
|
||||||
std::string protocol;///<Protocol of URL
|
std::string protocol;///<Protocol of URL
|
||||||
std::string port;///<Port of URL
|
std::string port;///<Port of URL
|
||||||
std::string path;///<Path after the first slash, not inclusive
|
std::string path;///<Path after the first slash (not inclusive) but before any question mark
|
||||||
|
std::string args;///<Everything after the question mark in the path, if it was present
|
||||||
};
|
};
|
||||||
|
|
||||||
}//HTTP namespace
|
}//HTTP namespace
|
||||||
|
|
Loading…
Add table
Reference in a new issue