From e371f479b6da6a5ce8f099c62bc62654c34280a0 Mon Sep 17 00:00:00 2001 From: Mattias Eriksson Date: Thu, 27 Jun 2024 22:25:23 +0200 Subject: [PATCH] Set plain/text Content-Type --- metrics-exporter-prometheus/src/exporter/http_listener.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/metrics-exporter-prometheus/src/exporter/http_listener.rs b/metrics-exporter-prometheus/src/exporter/http_listener.rs index 3096b0fa..874725d3 100644 --- a/metrics-exporter-prometheus/src/exporter/http_listener.rs +++ b/metrics-exporter-prometheus/src/exporter/http_listener.rs @@ -3,6 +3,7 @@ use std::net::SocketAddr; use http_body_util::Full; use hyper::{ body::{self, Bytes, Incoming}, + header::{HeaderValue, CONTENT_TYPE}, server::conn::http1::Builder as HyperHttpBuilder, service::service_fn, Request, Response, StatusCode, @@ -69,10 +70,12 @@ impl HttpListeningExporter { req: &Request, ) -> Response> { if is_allowed { - Response::new(match req.uri().path() { + let mut response = Response::new(match req.uri().path() { "/health" => "OK".into(), _ => handle.render().into(), - }) + }); + response.headers_mut().append(CONTENT_TYPE, HeaderValue::from_static("text/plain")); + response } else { Self::new_forbidden_response() }