8 // Extremely rudimentary URL parsing.
9 bool parse_url(const string &url, string *protocol, string *host, string *port, string *path)
11 if (url.find("http://") != 0) {
17 string rest = url.substr(strlen("http://"));
18 size_t split = rest.find_first_of(":/");
19 if (split == string::npos) {
27 *host = string(rest.begin(), rest.begin() + split);
28 char ch = rest[split]; // Colon or slash.
29 rest = string(rest.begin() + split + 1, rest.end());
33 split = rest.find_first_of('/');
34 if (split == string::npos) {
40 // http://foo:1234/bar
41 *port = string(rest.begin(), rest.begin() + split);
42 *path = string(rest.begin() + split, rest.end());