MCPcopy Create free account
hub / github.com/BlueAndi/Pixelix / begin

Method begin

lib/AsyncHttpClient/src/AsyncHttpClient.cpp:210–361  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

208}
209
210bool AsyncHttpClient::begin(const String& url)
211{
212 bool status = true;
213 int index = url.indexOf(':');
214 bool isReqOpen = false;
215
216 if (nullptr == m_processTaskHandle)
217 {
218 status = createProcessTask();
219 }
220
221 /* Protect against concurrent access. */
222 {
223 MutexGuard<Mutex> guard(m_mutex);
224
225 isReqOpen = m_isReqOpen;
226 }
227
228 /* Task couldn't be created? */
229 if (false == status)
230 {
231 ;
232 }
233 /* If a response is pending, abort. */
234 else if (true == isReqOpen)
235 {
236 status = false;
237 }
238 /* The URL must contain the protocol. */
239 else if (0 > index)
240 {
241 LOG_ERROR("Failed to parse protocol.");
242 status = false;
243 }
244 else
245 {
246 int patternBegin = 0;
247
248 clear();
249
250 /* Get protocol http or https */
251 String protocol = url.substring(patternBegin, index);
252 patternBegin = index + 3; /* Overstep '://' too. */
253
254 /* Determine port from protocol */
255 if (protocol == "http")
256 {
257 m_port = HTTP_PORT;
258 m_isSecure = false;
259 }
260 else if (protocol == "https")
261 {
262 m_port = HTTPS_PORT;
263 m_isSecure = true;
264 }
265 else
266 {
267 status = false;

Callers 2

equalsIgnoreCaseMethod · 0.45
getHeaderMethod · 0.45

Calls 7

indexOfMethod · 0.80
substringMethod · 0.80
c_strMethod · 0.80
removeMethod · 0.80
toIntMethod · 0.80
clearMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected