if (SYSINFO_RET_OK == (ret = get_http_page(hostname, path_str, port_str, request->timeout, &buffer, &error)))
#define HTTP_SCHEME_STR "http:
#define ZBX_MAX_WEBPAGE_SIZE (1 * 1024 * 1024)
#define HTTPS_SCHEME_STR "https:
static int detect_url(const char *host)
if (NULL != strpbrk(host, "/@#?[]"))
if (NULL != (p = strchr(host, ':')) && NULL == strchr(++p, ':'))
static int process_url(const char *host, const char *port, const char *path, char **url, char **error)
if ((NULL != port && '\0' != *port) || (NULL != path && '\0' != *path))
*error = zbx_strdup(*error,
"Parameters \"path\" and \"port\" must be empty if URL is specified in \"host\".");
if (0 == zbx_strncasecmp(host, HTTP_SCHEME_STR, ZBX_CONST_STRLEN(HTTP_SCHEME_STR)) ||
0 == zbx_strncasecmp(host, HTTPS_SCHEME_STR, ZBX_CONST_STRLEN(HTTPS_SCHEME_STR)))
if (0 == zbx_strncasecmp(host, HTTP_SCHEME_STR, ZBX_CONST_STRLEN(HTTP_SCHEME_STR)))
else if (NULL != (p = strstr(host, "://")) && (NULL == (delim = strpbrk(host, "/?#")) || delim > p))
*error = zbx_dsprintf(*error, "Unsupported scheme: %.*s.", (int)(p - host), host);
if (NULL != (p = strchr(host, '#')))
*url = zbx_dsprintf(*url, "%s%.*s", (0 == scheme_found ? HTTP_SCHEME_STR : ""), (int)(p - host), host);
*url = zbx_dsprintf(*url, "%s%s", (0 == scheme_found ? HTTP_SCHEME_STR : ""), host);
static int check_common_params(const char *host, const char *path, char **error)
const char *wrong_chr, URI_PROHIBIT_CHARS[] = {0x1,0x2,0x3,0x4,0x5,0x6,0x7,0x8,0x9,0xA,0xB,0xC,0xD,0xE,\