* parsing the url for all needed parameters * @param client Client& * @param url String * @param https bool * @return success bool */
| 112 | * @return success bool |
| 113 | */ |
| 114 | bool HTTPClient::begin(NetworkClient &client, String url) { |
| 115 | #ifdef HTTPCLIENT_1_1_COMPATIBLE |
| 116 | if (_tcpDeprecated) { |
| 117 | log_d("mix up of new and deprecated api"); |
| 118 | _canReuse = false; |
| 119 | end(); |
| 120 | } |
| 121 | #endif |
| 122 | |
| 123 | _client = &client; |
| 124 | |
| 125 | // check for : (http: or https:) |
| 126 | int index = url.indexOf(':'); |
| 127 | if (index < 0) { |
| 128 | log_d("failed to parse protocol"); |
| 129 | return false; |
| 130 | } |
| 131 | |
| 132 | String protocol = url.substring(0, index); |
| 133 | if (protocol != "http" && protocol != "https") { |
| 134 | log_d("unknown protocol '%s'", protocol.c_str()); |
| 135 | return false; |
| 136 | } |
| 137 | |
| 138 | _port = (protocol == "https" ? 443 : 80); |
| 139 | _secure = (protocol == "https"); |
| 140 | |
| 141 | #ifdef HTTPCLIENT_NOSECURE |
| 142 | if (_secure) { |
| 143 | return false; |
| 144 | } |
| 145 | #endif // HTTPCLIENT_NOSECURE |
| 146 | return beginInternal(url, protocol.c_str()); |
| 147 | } |
| 148 | |
| 149 | /** |
| 150 | * directly supply all needed parameters |
no test coverage detected