From f6df30d292437269556d936a5bdd5659ee4a463d Mon Sep 17 00:00:00 2001 From: tigercosmos Date: Wed, 16 Aug 2023 02:54:04 +0900 Subject: [PATCH] HttpResponseStatusCode initial value --- Packet++/header/HttpLayer.h | 2 +- Packet++/src/HttpLayer.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Packet++/header/HttpLayer.h b/Packet++/header/HttpLayer.h index dd6585583e..b808a27e7c 100644 --- a/Packet++/header/HttpLayer.h +++ b/Packet++/header/HttpLayer.h @@ -439,7 +439,7 @@ namespace pcpp constexpr bool operator==(const Value &otherValue) const { return m_value == otherValue; } constexpr bool operator!=(const Value &otherValue) const { return m_value != otherValue; } private: - Value m_value; + Value m_value = HttpStatusCodeError; }; // -------- Class HttpResponseLayer ----------------- diff --git a/Packet++/src/HttpLayer.cpp b/Packet++/src/HttpLayer.cpp index a2728d28fd..57d2d7f6b3 100644 --- a/Packet++/src/HttpLayer.cpp +++ b/Packet++/src/HttpLayer.cpp @@ -794,9 +794,9 @@ HttpResponseFirstLine::HttpResponseFirstLine(HttpResponseLayer* httpResponse) : HttpResponseFirstLine::HttpResponseFirstLine(HttpResponseLayer* httpResponse, HttpVersion version, HttpResponseStatusCode statusCode, std::string statusCodeString) { - if (m_StatusCode.isUnsupportedCode()) + if (statusCode.isUnsupportedCode()) { - m_Exception.setMessage("Status code supplied was " + statusCodeExplanationStringMap.at(m_StatusCode)); + m_Exception.setMessage("Status code supplied was " + statusCodeExplanationStringMap.at(statusCode)); throw m_Exception; } @@ -812,9 +812,9 @@ HttpResponseFirstLine::HttpResponseFirstLine(HttpResponseLayer* httpResponse, H m_Version = version; if(statusCodeString == "") { - statusCodeString = statusCodeExplanationStringMap.at(statusCode); + statusCodeString = statusCodeExplanationStringMap.at(m_StatusCode); } - std::string firstLine = "HTTP/" + VersionEnumToString[m_Version] + " " + statusCode.toString() + " " + statusCodeString + "\r\n"; + std::string firstLine = "HTTP/" + VersionEnumToString[m_Version] + " " + m_StatusCode.toString() + " " + statusCodeString + "\r\n"; m_FirstLineEndOffset = firstLine.length();