** 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/>.
"golang.org/x/net/html/charset"
"golang.org/x/text/transform"
"golang.zabbix.com/agent2/internal/agent"
"golang.zabbix.com/agent2/pkg/version"
"golang.zabbix.com/sdk/log"
// Get makes a GET request to the provided web page url, using an http client, provides a response dump if dump
func Get(url string, timeout time.Duration, dump bool) (string, error) {
req, err := http.NewRequest("GET", url, nil)
return "", fmt.Errorf("Cannot create new request: %w", err)
req.Header = map[string][]string{
"User-Agent": {"Zabbix " + version.Long()},
Transport: &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
Proxy: http.ProxyFromEnvironment,
DialContext: (&net.Dialer{
LocalAddr: &net.TCPAddr{IP: net.ParseIP(agent.Options.SourceIP), Port: 0},
CheckRedirect: disableRedirect,
resp, err := client.Do(req)
return "", fmt.Errorf("Cannot get content of web page: %w", err)