From 225c9768dc96ced62a6984ff72763d8120bce83b Mon Sep 17 00:00:00 2001 From: Simon Farre Date: Thu, 26 Sep 2019 18:15:13 +0200 Subject: [PATCH] Exposes the request headers, as const reference, so that iteration over all headers can be done, instead of solely having to query with request::header(std::string const& key). Since it exposes using const reference, no mutation can be done. --- src/served/request.cpp | 6 ++++++ src/served/request.hpp | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/src/served/request.cpp b/src/served/request.cpp index c8a5199..69d8d9e 100644 --- a/src/served/request.cpp +++ b/src/served/request.cpp @@ -138,4 +138,10 @@ request::body() const return _body; } +const request::header_list& +request::get_headers() const +{ + return _headers; +} + } // served diff --git a/src/served/request.hpp b/src/served/request.hpp index 602a3cf..a5c07f5 100644 --- a/src/served/request.hpp +++ b/src/served/request.hpp @@ -166,6 +166,13 @@ class request */ const std::string body() const; + /* + * Get all headers. Read-only, to be used when one wants to iterate over the headers. + * + * @return header_list as const reference. + */ + const header_list& get_headers() const; + public: // ----- public members -----