mirror of
https://github.com/geode-sdk/geode.git
synced 2025-03-13 22:49:52 -04:00
header(sv) works the same as it used, added headersWithName(sv) to get the whole vector
This commit is contained in:
parent
ed493f8460
commit
9c61f74efd
2 changed files with 12 additions and 9 deletions
|
@ -82,7 +82,8 @@ namespace geode::utils::web {
|
|||
Result<> into(std::filesystem::path const& path) const;
|
||||
|
||||
std::vector<std::string> headers() const;
|
||||
std::optional<std::string> header(std::string_view name, int index = 0) const;
|
||||
std::optional<std::string> header(std::string_view name) const;
|
||||
std::optional<std::vector<std::string>> headersWithName(std::string_view name) const;
|
||||
};
|
||||
|
||||
class GEODE_DLL WebProgress final {
|
||||
|
|
|
@ -145,14 +145,16 @@ std::vector<std::string> WebResponse::headers() const {
|
|||
return map::keys(m_impl->m_headers);
|
||||
}
|
||||
|
||||
std::optional<std::string> WebResponse::header(std::string_view name, int index) const {
|
||||
auto str = std::string(name);
|
||||
if (m_impl->m_headers.contains(str)) {
|
||||
const auto headersWithName = m_impl->m_headers.at(str);
|
||||
if (headersWithName.size() > index) {
|
||||
return headersWithName.at(index);
|
||||
}
|
||||
return std::nullopt;
|
||||
std::optional<std::string> WebResponse::header(std::string_view name) const {
|
||||
if (auto str = std::string(name); m_impl->m_headers.contains(str)) {
|
||||
return m_impl->m_headers.at(str).at(0);
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::optional<std::vector<std::string>> WebResponse::headersWithName(std::string_view name) const {
|
||||
if (auto str = std::string(name); m_impl->m_headers.contains(str)) {
|
||||
return m_impl->m_headers.at(str);
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue