Skip to content

Commit

Permalink
Merge ef059df into 1d36d42
Browse files Browse the repository at this point in the history
  • Loading branch information
gjasny committed Mar 9, 2021
2 parents 1d36d42 + ef059df commit 5d38d6a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pull/src/handler.cc
Expand Up @@ -96,7 +96,7 @@ static std::size_t WriteResponse(struct mg_connection* conn,
const std::string& body) {
mg_printf(conn,
"HTTP/1.1 200 OK\r\n"
"Content-Type: text/plain\r\n");
"Content-Type: text/plain; charset=utf-8\r\n");

#ifdef HAVE_ZLIB
auto acceptsGzip = IsEncodingAccepted(conn, "gzip");
Expand Down
19 changes: 19 additions & 0 deletions pull/tests/integration/integration_test.cc
Expand Up @@ -31,6 +31,7 @@ class IntegrationTest : public testing::Test {
struct Resonse {
long code = 0;
std::string body;
std::string contentType;
};

std::function<void(CURL*)> fetchPrePerform_;
Expand Down Expand Up @@ -59,6 +60,12 @@ class IntegrationTest : public testing::Test {

curl_easy_getinfo(curl.get(), CURLINFO_RESPONSE_CODE, &response.code);

char* ct = nullptr;
curl_easy_getinfo(curl.get(), CURLINFO_CONTENT_TYPE, &ct);
if (ct) {
response.contentType = ct;
}

return response;
}

Expand Down Expand Up @@ -225,5 +232,17 @@ TEST_F(IntegrationTest, shouldDealWithExpiredCollectables) {
EXPECT_THAT(metrics.body, Not(HasSubstr(second_counter_name)));
}

TEST_F(IntegrationTest, shouldSendBodyAsUtf8) {
const std::string counter_name = "example_total";
auto registry = RegisterSomeCounter(counter_name, default_metrics_path_);

const auto metrics = FetchMetrics(default_metrics_path_);

// check content type

ASSERT_EQ(metrics.code, 200);
EXPECT_THAT(metrics.contentType, HasSubstr("utf-8"));
}

} // namespace
} // namespace prometheus

0 comments on commit 5d38d6a

Please sign in to comment.