MCPcopy Create free account
hub / github.com/ClickHouse/ai-sdk-cpp / parse_base_url

Method parse_base_url

src/http/http_request_handler.cpp:17–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15}
16
17HttpConfig HttpRequestHandler::parse_base_url(const std::string& base_url) {
18 HttpConfig config;
19 std::string url = base_url;
20
21 // Extract protocol
22 if (url.starts_with("https://")) {
23 url = url.substr(8);
24 config.use_ssl = true;
25 } else if (url.starts_with("http://")) {
26 url = url.substr(7);
27 config.use_ssl = false;
28 } else {
29 config.use_ssl = true;
30 }
31
32 // Extract host and path
33 auto pos = url.find('/');
34 config.host = (pos != std::string::npos) ? url.substr(0, pos) : url;
35 config.base_path = (pos != std::string::npos) ? url.substr(pos) : "";
36
37 // Remove trailing slash from base_path if present
38 if (!config.base_path.empty() && config.base_path.back() == '/') {
39 config.base_path.pop_back();
40 }
41
42 return config;
43}
44
45GenerateResult HttpRequestHandler::post(const std::string& path,
46 const httplib::Headers& headers,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected