From: Marc Fournier Date: Tue, 1 Nov 2016 10:15:24 +0000 (+0100) Subject: write_prometheus: add support for libmicrohttpd 0.9.45+ X-Git-Tag: collectd-5.7.0~35^2~2 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=dc57f6e8f2394b51dd35d1d8231ef110c075b831;p=collectd.git write_prometheus: add support for libmicrohttpd 0.9.45+ Add switch on MHD_VERSION to support both legacy and modern MHD functions. `MHD_create_response_from_data()` is deprecated since libmicrohttpd 0.9.5 and makes the build fail since 0.9.45. --- diff --git a/src/write_prometheus.c b/src/write_prometheus.c index 6c882781..6fb5a866 100644 --- a/src/write_prometheus.c +++ b/src/write_prometheus.c @@ -210,8 +210,14 @@ static int http_handler(void *cls, struct MHD_Connection *connection, else format_text(buffer); - struct MHD_Response *res = MHD_create_response_from_data( + struct MHD_Response *res = +#if defined(MHD_VERSION) && MHD_VERSION >= 0x00090500 + MHD_create_response_from_buffer( + simple.len, simple.data, MHD_RESPMEM_MUST_COPY); +#else + MHD_create_response_from_data( simple.len, simple.data, /* must_free = */ 0, /* must_copy = */ 1); +#endif MHD_add_response_header(res, MHD_HTTP_HEADER_CONTENT_TYPE, want_proto ? CONTENT_TYPE_PROTO : CONTENT_TYPE_TEXT);