3 #include "AudioTools/CoreAudio/AudioBasic/Str.h"
4 #include "AudioTools/CoreAudio/AudioLogger.h"
28 Url(
const char* url) {
33 const char* url() {
return urlStr.
c_str(); }
34 const char* path() {
return pathStr.
c_str(); }
35 const char* host() {
return hostStr.
c_str(); }
36 const char* protocol() {
return protocolStr.
c_str(); }
37 const char* urlRoot() {
38 return urlRootStr.
c_str();
40 int port() {
return portInt; }
41 bool isSecure() {
return portInt == 443; }
43 void setUrl(
const char* url) {
44 LOGD(
"setUrl %s", url);
60 int protocolEnd = urlStr.
indexOf(
"://");
61 if (protocolEnd == -1) {
64 protocolStr.
substring(urlStr, 0, protocolEnd);
65 int pathStart = urlStr.
indexOf(
"/", protocolEnd + 4);
66 int portStart = urlStr.
indexOf(
":", protocolEnd + 3);
68 if (pathStart>=0) portStart = portStart < pathStart ? portStart : -1;
69 int hostEnd = portStart != -1 ? portStart : pathStart;
74 hostStr.
substring(urlStr, protocolEnd + 3, hostEnd);
76 portInt = atoi(urlStr.
c_str() + portStart + 1);
94 urlRootStr.
substring(urlStr, 0, pathStart);
96 LOGI(
"url->%s", url());
97 LOGI(
"host->%s", host());
98 LOGI(
"protocol->%s", protocol());
99 LOGI(
"path->%s", path());
100 LOGI(
"port->%d", port());