MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / check_host_name

Method check_host_name

examples/server/httplib.h:8276–8302  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8274}
8275
8276inline bool SSLClient::check_host_name(const char *pattern,
8277 size_t pattern_len) const {
8278 if (host_.size() == pattern_len && host_ == pattern) { return true; }
8279
8280 // Wildcard match
8281 // https://bugs.launchpad.net/ubuntu/+source/firefox-3.0/+bug/376484
8282 std::vector<std::string> pattern_components;
8283 detail::split(&pattern[0], &pattern[pattern_len], '.',
8284 [&](const char *b, const char *e) {
8285 pattern_components.emplace_back(std::string(b, e));
8286 });
8287
8288 if (host_components_.size() != pattern_components.size()) { return false; }
8289
8290 auto itr = pattern_components.begin();
8291 for (const auto &h : host_components_) {
8292 auto &p = *itr;
8293 if (p != h && p != "*") {
8294 auto partial_match = (p.size() > 0 && p[p.size() - 1] == '*' &&
8295 !p.compare(0, p.size() - 1, h));
8296 if (!partial_match) { return false; }
8297 }
8298 ++itr;
8299 }
8300
8301 return true;
8302}
8303#endif
8304
8305// Universal client implementation

Callers

nothing calls this directly

Calls 5

splitFunction · 0.70
stringFunction · 0.70
sizeMethod · 0.45
beginMethod · 0.45
compareMethod · 0.45

Tested by

no test coverage detected