feat(headers): getContentType and getHost
This commit is contained in:
parent
e921290d8f
commit
e43bf72cd6
@ -8,7 +8,7 @@
|
||||
|
||||
std::optional<size_t> 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<size_t> HttpHeaders::getContentLength() const
|
||||
}
|
||||
}
|
||||
|
||||
std::optional<std::string> HttpHeaders::getContentType() const
|
||||
{
|
||||
const auto &value = this->get("Content-Type");
|
||||
if (value.empty())
|
||||
{
|
||||
return std::nullopt;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
std::optional<std::string> 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)
|
||||
{
|
||||
|
||||
|
||||
@ -36,6 +36,8 @@ class HttpHeaders
|
||||
std::string toString() const;
|
||||
|
||||
std::optional<size_t> getContentLength() const;
|
||||
std::optional<std::string> getContentType() const;
|
||||
std::optional<std::string> getHost() const;
|
||||
|
||||
private:
|
||||
std::unordered_map<std::string, std::string> headers_;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user