connectivity: conclude the check as soon as we see the magic header

No need to read the rest of the reponse.
This commit is contained in:
Lubomir Rintel 2017-03-22 15:28:06 +01:00
parent 71b8d16eb8
commit ac0f454cfb

View file

@ -204,7 +204,6 @@ typedef struct {
size_t msg_size;
char *msg;
struct curl_slist *request_headers;
gboolean online_header;
} ConCheckCbData;
static void
@ -276,12 +275,6 @@ curl_check_connectivity (CURLM *mhandle, CURLMcode ret)
goto cleanup;
}
if (cb_data->online_header) {
_LOGD ("check for uri '%s' with Status header successful.", cb_data->uri);
new_state = NM_CONNECTIVITY_FULL;
goto cleanup;
}
/* Check response */
if (cb_data->msg && g_str_has_prefix (cb_data->msg, cb_data->response)) {
_LOGD ("Check for uri '%s' successful.", cb_data->uri);
@ -414,7 +407,9 @@ easy_header_cb (char *buffer, size_t size, size_t nitems, void *userdata)
if ( len >= sizeof (HEADER_STATUS_ONLINE) - 1
&& !g_ascii_strncasecmp (buffer, HEADER_STATUS_ONLINE, sizeof (HEADER_STATUS_ONLINE) - 1)) {
cb_data->online_header = TRUE;
_LOGD ("check for uri '%s' with Status header successful.", cb_data->uri);
finish_cb_data (cb_data, NM_CONNECTIVITY_FULL);
return 0;
}
return len;