From 7ba9f6b2337f698f9430ec5a4707c2813971d3a1 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Fri, 17 Feb 2023 20:52:53 +0000 Subject: [PATCH] http_utils update using std::span --- src/lib/utils/http_util/http_util.cpp | 2 +- src/lib/utils/http_util/http_util.h | 7 ++++--- src/lib/x509/ocsp.h | 3 ++- src/lib/x509/x509_crl.cpp | 4 ++-- src/lib/x509/x509_crl.h | 3 ++- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/lib/utils/http_util/http_util.cpp b/src/lib/utils/http_util/http_util.cpp index 14440ac3bd9..6e82da95074 100644 --- a/src/lib/utils/http_util/http_util.cpp +++ b/src/lib/utils/http_util/http_util.cpp @@ -67,7 +67,7 @@ std::string http_transact(const std::string& hostname, return oss.str(); } -bool needs_url_encoding(char c) +inline bool needs_url_encoding(char c) { if(c >= 'A' && c <= 'Z') return false; diff --git a/src/lib/utils/http_util/http_util.h b/src/lib/utils/http_util/http_util.h index 8918b871b71..af5672b13ad 100644 --- a/src/lib/utils/http_util/http_util.h +++ b/src/lib/utils/http_util/http_util.h @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -40,7 +41,7 @@ class Response final Response() : m_status_code(0), m_status_message("Uninitialized") {} Response(unsigned int status_code, const std::string& status_message, - const std::vector& body, + std::span body, const std::map& headers) : m_status_code(status_code), m_status_message(status_message), @@ -49,7 +50,7 @@ class Response final unsigned int status_code() const { return m_status_code; } - const std::vector& body() const { return m_body; } + std::span body() const { return m_body; } const std::map& headers() const { return m_headers; } @@ -64,7 +65,7 @@ class Response final private: unsigned int m_status_code; std::string m_status_message; - std::vector m_body; + std::span m_body; std::map m_headers; }; diff --git a/src/lib/x509/ocsp.h b/src/lib/x509/ocsp.h index a4b9079c80e..bb1c771bc7e 100644 --- a/src/lib/x509/ocsp.h +++ b/src/lib/x509/ocsp.h @@ -14,6 +14,7 @@ #include #include +#include #include namespace Botan { @@ -148,7 +149,7 @@ class BOTAN_PUBLIC_API(2,0) Response final * Parses an OCSP response. * @param response_bits response bits received */ - Response(const std::vector& response_bits) : + Response(std::span response_bits) : Response(response_bits.data(), response_bits.size()) {} diff --git a/src/lib/x509/x509_crl.cpp b/src/lib/x509/x509_crl.cpp index dbebb758df1..bb6f43085fa 100644 --- a/src/lib/x509/x509_crl.cpp +++ b/src/lib/x509/x509_crl.cpp @@ -43,9 +43,9 @@ X509_CRL::X509_CRL(DataSource& src) load_data(src); } -X509_CRL::X509_CRL(const std::vector& vec) +X509_CRL::X509_CRL(std::span vec) { - DataSource_Memory src(vec.data(), vec.size()); + DataSource_Memory src(vec); load_data(src); } diff --git a/src/lib/x509/x509_crl.h b/src/lib/x509/x509_crl.h index d550cea77fd..6ba4b53f978 100644 --- a/src/lib/x509/x509_crl.h +++ b/src/lib/x509/x509_crl.h @@ -12,6 +12,7 @@ #include #include #include +#include namespace Botan { @@ -166,7 +167,7 @@ class BOTAN_PUBLIC_API(2,0) X509_CRL final : public X509_Object * Construct a CRL from a binary vector * @param vec the binary (DER) representation of the CRL */ - X509_CRL(const std::vector& vec); + X509_CRL(std::span vec); /** * Construct a CRL