| 362 | } |
| 363 | |
| 364 | http_connect_info https_client::get_host_info(std::string url) { |
| 365 | http_connect_info hci = { false, "http", "", 80}; |
| 366 | if (url.substr(0, 8) == "https://") { |
| 367 | hci.port = 443; |
| 368 | hci.is_ssl = true; |
| 369 | hci.scheme = url.substr(0, 5); |
| 370 | url = url.substr(8, url.length()); |
| 371 | } else if (url.substr(0, 7) == "http://") { |
| 372 | hci.scheme = url.substr(0, 4); |
| 373 | url = url.substr(7, url.length()); |
| 374 | } else if (url.substr(0, 11) == "discord.com") { |
| 375 | hci.scheme = "https"; |
| 376 | hci.is_ssl = true; |
| 377 | hci.port = 443; |
| 378 | } |
| 379 | size_t colon_pos = url.find(':'); |
| 380 | if (colon_pos != std::string::npos) { |
| 381 | hci.hostname = url.substr(0, colon_pos); |
| 382 | hci.port = atoi(url.substr(colon_pos + 1, url.length()).c_str()); |
| 383 | if (hci.port == 0) { |
| 384 | hci.port = 80; |
| 385 | } |
| 386 | } else { |
| 387 | hci.hostname = url; |
| 388 | } |
| 389 | return hci; |
| 390 | } |
| 391 | |
| 392 | } |