10 // Extremely rudimentary URL parsing.
11 bool parse_url(const string &url, string *protocol, string *host, string *port, string *path)
13 if (url.find("http://") != 0) {
19 string rest = url.substr(strlen("http://"));
20 size_t split = rest.find_first_of(":/");
21 if (split == string::npos) {
29 *host = string(rest.begin(), rest.begin() + split);
30 char ch = rest[split]; // Colon or slash.
31 rest = string(rest.begin() + split + 1, rest.end());
35 split = rest.find_first_of('/');
36 if (split == string::npos) {
42 // http://foo:1234/bar
43 *port = string(rest.begin(), rest.begin() + split);
44 *path = string(rest.begin() + split, rest.end());
55 Input *create_input(const std::string &stream_id, const std::string &url)
57 string protocol, host, port, path;
58 if (!parse_url(url, &protocol, &host, &port, &path)) {
61 if (protocol == "http") {
62 return new HTTPInput(stream_id, url);
67 Input *create_input(const InputProto &serialized)
69 string protocol, host, port, path;
70 if (!parse_url(serialized.url(), &protocol, &host, &port, &path)) {
73 if (protocol == "http") {
74 return new HTTPInput(serialized);