Parse an https URL into (host, path). Crude but enough for the mirrors we use.
| 132 | #ifdef _WIN32 |
| 133 | // Parse an https URL into (host, path). Crude but enough for the mirrors we use. |
| 134 | bool split_https_url(const std::string& url, std::wstring& host, std::wstring& path) { |
| 135 | const std::string p = "https://"; |
| 136 | if (url.rfind(p, 0) != 0) return false; |
| 137 | auto slash = url.find('/', p.size()); |
| 138 | std::string h = url.substr(p.size(), slash - p.size()); |
| 139 | std::string a = (slash == std::string::npos) ? "/" : url.substr(slash); |
| 140 | host.assign(h.begin(), h.end()); |
| 141 | path.assign(a.begin(), a.end()); |
| 142 | return true; |
| 143 | } |
| 144 | |
| 145 | // Synchronous WinHTTP GET. Writes response body to `out` on 200; returns |
| 146 | // (http_status, error string). |
no test coverage detected