From ac4f1c1887fff87ae576e19feedd516379ff2368 Mon Sep 17 00:00:00 2001
From: Lin Zhihao <59785146+LinZhihao-723@users.noreply.github.com>
Date: Thu, 14 Nov 2024 23:32:59 -0500
Subject: [PATCH] test(core): Update
 `network_reader_with_valid_http_header_kv_pairs` to verify the return value
 before parsing the read content into a JSON object. (#593)

---
 components/core/tests/test-NetworkReader.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/components/core/tests/test-NetworkReader.cpp b/components/core/tests/test-NetworkReader.cpp
index f32daef14..f2995f141 100644
--- a/components/core/tests/test-NetworkReader.cpp
+++ b/components/core/tests/test-NetworkReader.cpp
@@ -213,9 +213,10 @@ TEST_CASE("network_reader_with_valid_http_header_kv_pairs", "[NetworkReader]") {
             clp::NetworkReader::cDefaultBufferSize,
             valid_http_header_kv_pairs
     };
-    auto const content = nlohmann::json::parse(get_content(reader));
-    auto const& headers{content.at("headers")};
+    auto const content{get_content(reader)};
     REQUIRE(assert_curl_error_code(CURLE_OK, reader));
+    auto const parsed_content = nlohmann::json::parse(content);
+    auto const& headers{parsed_content.at("headers")};
     for (auto const& [key, value] : valid_http_header_kv_pairs) {
         REQUIRE((value == headers.at(key).get<std::string_view>()));
     }