MCPcopy Create free account
hub / github.com/WallBreaker2/op / parse_url

Function parse_url

libop/network/HttpClient.cpp:94–116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

92// --- URL utilities ---
93
94bool parse_url(const std::string &url, ParsedUrl &out) {
95 const std::wstring wurl = _s2wstring(url);
96 URL_COMPONENTS parts = {};
97 parts.dwStructSize = sizeof(parts);
98 parts.dwSchemeLength = (DWORD)-1;
99 parts.dwHostNameLength = (DWORD)-1;
100 parts.dwUrlPathLength = (DWORD)-1;
101 parts.dwExtraInfoLength = (DWORD)-1;
102 if (!WinHttpCrackUrl(wurl.c_str(), 0, 0, &parts)) {
103 return false;
104 }
105 out.secure = (parts.nScheme == INTERNET_SCHEME_HTTPS);
106 out.port = parts.nPort;
107 out.host.assign(parts.lpszHostName, parts.dwHostNameLength);
108 out.path.assign(parts.lpszUrlPath, parts.dwUrlPathLength);
109 if (parts.dwExtraInfoLength > 0) {
110 out.path.append(parts.lpszExtraInfo, parts.dwExtraInfoLength);
111 }
112 if (out.path.empty()) {
113 out.path = L"/";
114 }
115 return !out.host.empty();
116}
117
118bool normalize_endpoint(std::string &endpoint, const char *default_path_suffix) {
119 ParsedUrl parsed;

Callers 3

detectMethod · 0.85
normalize_endpointFunction · 0.85
ocrMethod · 0.85

Calls 2

_s2wstringFunction · 0.85
emptyMethod · 0.45

Tested by

no test coverage detected