1 /* 2 ** Zabbix 3 ** Copyright (C) 2001-2021 Zabbix SIA 4 ** 5 ** This program is free software; you can redistribute it and/or modify 6 ** it under the terms of the GNU General Public License as published by 7 ** the Free Software Foundation; either version 2 of the License, or 8 ** (at your option) any later version. 9 ** 10 ** This program is distributed in the hope that it will be useful, 11 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 ** GNU General Public License for more details. 14 ** 15 ** You should have received a copy of the GNU General Public License 16 ** along with this program; if not, write to the Free Software 17 ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 **/ 19 20 #ifndef ZABBIX_ZBXHTTP_H 21 #define ZABBIX_ZBXHTTP_H 22 23 #include "common.h" 24 25 int zbx_http_punycode_encode_url(char **url); 26 void zbx_http_url_encode(const char *source, char **result); 27 int zbx_http_url_decode(const char *source, char **result); 28 29 #ifdef HAVE_LIBCURL 30 31 typedef struct 32 { 33 char *data; 34 size_t allocated; 35 size_t offset; 36 } 37 zbx_http_response_t; 38 39 size_t zbx_curl_write_cb(void *ptr, size_t size, size_t nmemb, void *userdata); 40 size_t zbx_curl_ignore_cb(void *ptr, size_t size, size_t nmemb, void *userdata); 41 42 int zbx_http_prepare_callbacks(CURL *easyhandle, zbx_http_response_t *header, 43 zbx_http_response_t *body, void *header_cb, void *body_cb, char *errbuf, char **error); 44 int zbx_http_prepare_ssl(CURL *easyhandle, const char *ssl_cert_file, const char *ssl_key_file, 45 const char *ssl_key_password, unsigned char verify_peer, unsigned char verify_host, char **error); 46 int zbx_http_prepare_auth(CURL *easyhandle, unsigned char authtype, const char *username, const char *password, 47 char **error); 48 char *zbx_http_parse_header(char **headers); 49 50 int zbx_http_get(const char *url, const char *header, long timeout, char **out, long *response_code, char **error); 51 #endif 52 53 #endif 54