| 15 | } |
| 16 | |
| 17 | HttpConfig 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 | |
| 45 | GenerateResult HttpRequestHandler::post(const std::string& path, |
| 46 | const httplib::Headers& headers, |
nothing calls this directly
no outgoing calls
no test coverage detected