MCPcopy Create free account
hub / github.com/MemNixFS/MemNixFS / split_https_url

Function split_https_url

src/symbols/symbol_cache_http.cpp:134–143  ·  view source on GitHub ↗

Parse an https URL into (host, path). Crude but enough for the mirrors we use.

Source from the content-addressed store, hash-verified

132#ifdef _WIN32
133// Parse an https URL into (host, path). Crude but enough for the mirrors we use.
134bool 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).

Callers 1

winhttp_getFunction · 0.85

Calls 2

findMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected