diff --git a/webserv/http/HttpHeaders.cpp b/webserv/http/HttpHeaders.cpp index 534c603..e93b018 100644 --- a/webserv/http/HttpHeaders.cpp +++ b/webserv/http/HttpHeaders.cpp @@ -8,7 +8,7 @@ std::optional HttpHeaders::getContentLength() const { - const auto &value = get("Content-Length"); + const auto &value = this->get("Content-Length"); if (value.empty()) { return std::nullopt; @@ -23,6 +23,26 @@ std::optional HttpHeaders::getContentLength() const } } +std::optional HttpHeaders::getContentType() const +{ + const auto &value = this->get("Content-Type"); + if (value.empty()) + { + return std::nullopt; + } + return value; +} + +std::optional HttpHeaders::getHost() const +{ + const auto &value = this->get("Host"); + if (value.empty()) + { + return std::nullopt; + } + return value; +} + void HttpHeaders::add(const std::string &name, const std::string &value) // NOLINT(bugprone-easily-swappable-parameters) { diff --git a/webserv/http/HttpHeaders.hpp b/webserv/http/HttpHeaders.hpp index 865284f..3cd39fc 100644 --- a/webserv/http/HttpHeaders.hpp +++ b/webserv/http/HttpHeaders.hpp @@ -36,6 +36,8 @@ class HttpHeaders std::string toString() const; std::optional getContentLength() const; + std::optional getContentType() const; + std::optional getHost() const; private: std::unordered_map headers_;