Source
static int webdriver_session_query(zbx_webdriver_t *wd, const char *method, const char *command, const char *data,
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
** without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
static size_t curl_write_cb(void *ptr, size_t size, size_t nmemb, void *userdata)
{
size_t r_size = size * nmemb;
zbx_webdriver_t *wd = (zbx_webdriver_t *)userdata;
zbx_str_memcpy_alloc(&wd->data, &wd->data_alloc, &wd->data_offset, (const char *)ptr, r_size);
return r_size;
}
static size_t curl_header_cb(void *ptr, size_t size, size_t nmemb, void *userdata)
{
size_t r_size = size * nmemb;
zbx_webdriver_t *wd = (zbx_webdriver_t *)userdata;
zbx_strncpy_alloc(&wd->headers_in, &wd->headers_in_alloc, &wd->headers_in_offset, (const char *)ptr, r_size);
return r_size;
}
/******************************************************************************
* *
* Purpose: utility function for checking curl attribute setting errors *
* *
******************************************************************************/
static int webdriver_curl_check_error(CURLcode err, CURLoption opt, char **error)
{
if (CURLE_OK == err)
return SUCCEED;
*error = zbx_dsprintf(NULL, "cannot set cURL option %u: %s.", opt, curl_easy_strerror(err));
return FAIL;
}