summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2023-07-29 11:01:47 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2023-07-29 11:01:47 +0100
commit9856760c8e8d03e3f896755cc0f78932a82d509e (patch)
tree950b324a47cbca64407f8749a6daa35b8988f327
parentRemove magic number and string resize hack (diff)
downloadicespider-9856760c8e8d03e3f896755cc0f78932a82d509e.tar.bz2
icespider-9856760c8e8d03e3f896755cc0f78932a82d509e.tar.xz
icespider-9856760c8e8d03e3f896755cc0f78932a82d509e.zip
Rename internal paramGet functions to disambiguate from the typed ones
-rw-r--r--icespider/core/ihttpRequest.cpp6
-rw-r--r--icespider/core/ihttpRequest.h18
-rw-r--r--icespider/fcgi/cgiRequestBase.cpp8
-rw-r--r--icespider/fcgi/cgiRequestBase.h8
-rw-r--r--icespider/testing/testRequest.cpp8
-rw-r--r--icespider/testing/testRequest.h8
-rw-r--r--icespider/unittests/testFcgi.cpp48
-rw-r--r--icespider/unittests/testPerf.cpp8
8 files changed, 56 insertions, 56 deletions
diff --git a/icespider/core/ihttpRequest.cpp b/icespider/core/ihttpRequest.cpp
index e396b5a..6e04bf5 100644
--- a/icespider/core/ihttpRequest.cpp
+++ b/icespider/core/ihttpRequest.cpp
@@ -32,7 +32,7 @@ namespace IceSpider {
{
try {
return Slicer::StreamDeserializerFactory::createNew(
- getEnv(E::CONTENT_TYPE) / []() -> std::string_view {
+ getEnvStr(E::CONTENT_TYPE) / []() -> std::string_view {
throw Http400_BadRequest();
},
getInputStream());
@@ -110,7 +110,7 @@ namespace IceSpider {
ContentTypeSerializer
IHttpRequest::getSerializer(const IRouteHandler * handler) const
{
- auto acceptHdr = getHeaderParam(H::ACCEPT);
+ auto acceptHdr = getHeaderParamStr(H::ACCEPT);
if (acceptHdr) {
auto accepts = parseAccept(*acceptHdr);
auto & strm = getOutputStream();
@@ -134,7 +134,7 @@ namespace IceSpider {
}
OptionalString
- IHttpRequest::getURLParam(const unsigned int & idx) const
+ IHttpRequest::getURLParamStr(const unsigned int & idx) const
{
auto & url = getRequestPath();
if (idx >= url.size()) {
diff --git a/icespider/core/ihttpRequest.h b/icespider/core/ihttpRequest.h
index 451fe67..5141068 100644
--- a/icespider/core/ihttpRequest.h
+++ b/icespider/core/ihttpRequest.h
@@ -44,11 +44,11 @@ namespace IceSpider {
[[nodiscard]] virtual PathElements & getRequestPath() = 0;
[[nodiscard]] virtual HttpMethod getRequestMethod() const = 0;
- [[nodiscard]] OptionalString getURLParam(const unsigned int &) const;
- [[nodiscard]] virtual OptionalString getQueryStringParam(const std::string_view &) const = 0;
- [[nodiscard]] virtual OptionalString getHeaderParam(const std::string_view &) const = 0;
- [[nodiscard]] virtual OptionalString getCookieParam(const std::string_view &) const = 0;
- [[nodiscard]] virtual OptionalString getEnv(const std::string_view &) const = 0;
+ [[nodiscard]] OptionalString getURLParamStr(const unsigned int &) const;
+ [[nodiscard]] virtual OptionalString getQueryStringParamStr(const std::string_view &) const = 0;
+ [[nodiscard]] virtual OptionalString getHeaderParamStr(const std::string_view &) const = 0;
+ [[nodiscard]] virtual OptionalString getCookieParamStr(const std::string_view &) const = 0;
+ [[nodiscard]] virtual OptionalString getEnvStr(const std::string_view &) const = 0;
[[nodiscard]] virtual bool isSecure() const = 0;
[[nodiscard]] static Accepted parseAccept(std::string_view);
[[nodiscard]] virtual Slicer::DeserializerPtr getDeserializer() const;
@@ -91,7 +91,7 @@ namespace IceSpider {
[[nodiscard]] T
getURLParam(unsigned int n) const
{
- return *getFrom<T, unsigned int>(n, &IHttpRequest::getURLParam);
+ return *getFrom<T, unsigned int>(n, &IHttpRequest::getURLParamStr);
}
template<typename T>
@@ -139,21 +139,21 @@ namespace IceSpider {
[[nodiscard]] std::optional<T>
getQueryStringParam(const std::string_view & key) const
{
- return getFrom<T, std::string_view>(key, &IHttpRequest::getQueryStringParam);
+ return getFrom<T, std::string_view>(key, &IHttpRequest::getQueryStringParamStr);
}
template<typename T>
[[nodiscard]] std::optional<T>
getHeaderParam(const std::string_view & key) const
{
- return getFrom<T, std::string_view>(key, &IHttpRequest::getHeaderParam);
+ return getFrom<T, std::string_view>(key, &IHttpRequest::getHeaderParamStr);
}
template<typename T>
[[nodiscard]] std::optional<T>
getCookieParam(const std::string_view & key) const
{
- return getFrom<T, std::string_view>(key, &IHttpRequest::getCookieParam);
+ return getFrom<T, std::string_view>(key, &IHttpRequest::getCookieParamStr);
}
virtual void response(short, const std::string_view &) const = 0;
diff --git a/icespider/fcgi/cgiRequestBase.cpp b/icespider/fcgi/cgiRequestBase.cpp
index 844a3db..6423995 100644
--- a/icespider/fcgi/cgiRequestBase.cpp
+++ b/icespider/fcgi/cgiRequestBase.cpp
@@ -150,19 +150,19 @@ namespace IceSpider {
}
OptionalString
- CgiRequestBase::getQueryStringParam(const std::string_view & key) const
+ CgiRequestBase::getQueryStringParamStr(const std::string_view & key) const
{
return optionalLookup(key, qsmap);
}
OptionalString
- CgiRequestBase::getCookieParam(const std::string_view & key) const
+ CgiRequestBase::getCookieParamStr(const std::string_view & key) const
{
return optionalLookup(key, cookiemap);
}
OptionalString
- CgiRequestBase::getEnv(const std::string_view & key) const
+ CgiRequestBase::getEnvStr(const std::string_view & key) const
{
return optionalLookup(key, envmap);
}
@@ -174,7 +174,7 @@ namespace IceSpider {
}
OptionalString
- CgiRequestBase::getHeaderParam(const std::string_view & key) const
+ CgiRequestBase::getHeaderParamStr(const std::string_view & key) const
{
return optionalLookup(key, hdrmap);
}
diff --git a/icespider/fcgi/cgiRequestBase.h b/icespider/fcgi/cgiRequestBase.h
index 4053f0c..c83264d 100644
--- a/icespider/fcgi/cgiRequestBase.h
+++ b/icespider/fcgi/cgiRequestBase.h
@@ -30,10 +30,10 @@ namespace IceSpider {
[[nodiscard]] const PathElements & getRequestPath() const override;
[[nodiscard]] PathElements & getRequestPath() override;
[[nodiscard]] HttpMethod getRequestMethod() const override;
- [[nodiscard]] OptionalString getQueryStringParam(const std::string_view & key) const override;
- [[nodiscard]] OptionalString getHeaderParam(const std::string_view & key) const override;
- [[nodiscard]] OptionalString getCookieParam(const std::string_view & key) const override;
- [[nodiscard]] OptionalString getEnv(const std::string_view & key) const override;
+ [[nodiscard]] OptionalString getQueryStringParamStr(const std::string_view & key) const override;
+ [[nodiscard]] OptionalString getHeaderParamStr(const std::string_view & key) const override;
+ [[nodiscard]] OptionalString getCookieParamStr(const std::string_view & key) const override;
+ [[nodiscard]] OptionalString getEnvStr(const std::string_view & key) const override;
[[nodiscard]] bool isSecure() const override;
void response(short, const std::string_view &) const override;
diff --git a/icespider/testing/testRequest.cpp b/icespider/testing/testRequest.cpp
index 552987c..3657117 100644
--- a/icespider/testing/testRequest.cpp
+++ b/icespider/testing/testRequest.cpp
@@ -44,7 +44,7 @@ namespace IceSpider {
}
OptionalString
- TestRequest::getEnv(const std::string_view & key) const
+ TestRequest::getEnvStr(const std::string_view & key) const
{
return get(key, env);
}
@@ -56,19 +56,19 @@ namespace IceSpider {
}
OptionalString
- TestRequest::getQueryStringParam(const std::string_view & key) const
+ TestRequest::getQueryStringParamStr(const std::string_view & key) const
{
return get(key, qs);
}
OptionalString
- TestRequest::getCookieParam(const std::string_view & key) const
+ TestRequest::getCookieParamStr(const std::string_view & key) const
{
return get(key, cookies);
}
OptionalString
- TestRequest::getHeaderParam(const std::string_view & key) const
+ TestRequest::getHeaderParamStr(const std::string_view & key) const
{
return get(key, hdr);
}
diff --git a/icespider/testing/testRequest.h b/icespider/testing/testRequest.h
index e274227..60bfcc5 100644
--- a/icespider/testing/testRequest.h
+++ b/icespider/testing/testRequest.h
@@ -21,10 +21,10 @@ namespace IceSpider {
const PathElements & getRequestPath() const override;
PathElements & getRequestPath() override;
HttpMethod getRequestMethod() const override;
- OptionalString getEnv(const std::string_view & key) const override;
- OptionalString getQueryStringParam(const std::string_view & key) const override;
- OptionalString getCookieParam(const std::string_view & key) const override;
- OptionalString getHeaderParam(const std::string_view & key) const override;
+ OptionalString getEnvStr(const std::string_view & key) const override;
+ OptionalString getQueryStringParamStr(const std::string_view & key) const override;
+ OptionalString getCookieParamStr(const std::string_view & key) const override;
+ OptionalString getHeaderParamStr(const std::string_view & key) const override;
bool isSecure() const override;
void setQueryStringParam(const std::string_view &, const OptionalString &);
void setHeaderParam(const std::string_view &, const OptionalString &);
diff --git a/icespider/unittests/testFcgi.cpp b/icespider/unittests/testFcgi.cpp
index 1df7411..e6508b3 100644
--- a/icespider/unittests/testFcgi.cpp
+++ b/icespider/unittests/testFcgi.cpp
@@ -138,57 +138,57 @@ BOOST_AUTO_TEST_CASE(script_name_foobar)
BOOST_AUTO_TEST_CASE(query_string_empty)
{
TestRequest r(this, {{"SCRIPT_NAME=/foo/bar", "QUERY_STRING="}});
- BOOST_REQUIRE(!r.getQueryStringParam(""));
+ BOOST_REQUIRE(!r.getQueryStringParamStr(""));
}
BOOST_AUTO_TEST_CASE(query_string_one)
{
TestRequest r(this, {{"SCRIPT_NAME=/foo/bar", "QUERY_STRING=one=1"}});
- BOOST_REQUIRE(!r.getQueryStringParam(""));
- BOOST_REQUIRE_EQUAL("1", *r.getQueryStringParam("one"));
+ BOOST_REQUIRE(!r.getQueryStringParamStr(""));
+ BOOST_REQUIRE_EQUAL("1", *r.getQueryStringParamStr("one"));
}
BOOST_AUTO_TEST_CASE(query_string_two)
{
TestRequest r(this, {{"SCRIPT_NAME=/foo/bar", "QUERY_STRING=one=1&two=2"}});
- BOOST_REQUIRE(!r.getQueryStringParam(""));
- BOOST_REQUIRE_EQUAL("1", *r.getQueryStringParam("one"));
- BOOST_REQUIRE_EQUAL("2", *r.getQueryStringParam("two"));
+ BOOST_REQUIRE(!r.getQueryStringParamStr(""));
+ BOOST_REQUIRE_EQUAL("1", *r.getQueryStringParamStr("one"));
+ BOOST_REQUIRE_EQUAL("2", *r.getQueryStringParamStr("two"));
}
BOOST_AUTO_TEST_CASE(query_string_three)
{
TestRequest r(this, {{"SCRIPT_NAME=/foo/bar", "QUERY_STRING=one=1&two=2&three=3"}});
- BOOST_REQUIRE(!r.getQueryStringParam(""));
- BOOST_REQUIRE_EQUAL("1", *r.getQueryStringParam("one"));
- BOOST_REQUIRE_EQUAL("2", *r.getQueryStringParam("two"));
- BOOST_REQUIRE_EQUAL("3", *r.getQueryStringParam("three"));
+ BOOST_REQUIRE(!r.getQueryStringParamStr(""));
+ BOOST_REQUIRE_EQUAL("1", *r.getQueryStringParamStr("one"));
+ BOOST_REQUIRE_EQUAL("2", *r.getQueryStringParamStr("two"));
+ BOOST_REQUIRE_EQUAL("3", *r.getQueryStringParamStr("three"));
}
BOOST_AUTO_TEST_CASE(query_string_urlencoding)
{
TestRequest r(this, {{"SCRIPT_NAME=/foo/bar", "QUERY_STRING=url+%65ncoded=%53tring%2e"}});
- BOOST_REQUIRE(!r.getQueryStringParam(""));
- BOOST_REQUIRE(r.getQueryStringParam("url encoded"));
- BOOST_REQUIRE_EQUAL("String.", *r.getQueryStringParam("url encoded"));
+ BOOST_REQUIRE(!r.getQueryStringParamStr(""));
+ BOOST_REQUIRE(r.getQueryStringParamStr("url encoded"));
+ BOOST_REQUIRE_EQUAL("String.", *r.getQueryStringParamStr("url encoded"));
}
BOOST_AUTO_TEST_CASE(query_string_three_emptyVal)
{
TestRequest r(this, {{"SCRIPT_NAME=/foo/bar", "QUERY_STRING=one=1&two=&three=3"}});
- BOOST_REQUIRE(!r.getQueryStringParam(""));
- BOOST_REQUIRE_EQUAL("1", *r.getQueryStringParam("one"));
- BOOST_REQUIRE_EQUAL("", *r.getQueryStringParam("two"));
- BOOST_REQUIRE_EQUAL("3", *r.getQueryStringParam("three"));
+ BOOST_REQUIRE(!r.getQueryStringParamStr(""));
+ BOOST_REQUIRE_EQUAL("1", *r.getQueryStringParamStr("one"));
+ BOOST_REQUIRE_EQUAL("", *r.getQueryStringParamStr("two"));
+ BOOST_REQUIRE_EQUAL("3", *r.getQueryStringParamStr("three"));
}
BOOST_AUTO_TEST_CASE(query_string_three_noVal)
{
TestRequest r(this, {{"SCRIPT_NAME=/foo/bar", "QUERY_STRING=one=1&two&three=3"}});
- BOOST_REQUIRE(!r.getQueryStringParam(""));
- BOOST_REQUIRE_EQUAL("1", *r.getQueryStringParam("one"));
- BOOST_REQUIRE_EQUAL("", *r.getQueryStringParam("two"));
- BOOST_REQUIRE_EQUAL("3", *r.getQueryStringParam("three"));
+ BOOST_REQUIRE(!r.getQueryStringParamStr(""));
+ BOOST_REQUIRE_EQUAL("1", *r.getQueryStringParamStr("one"));
+ BOOST_REQUIRE_EQUAL("", *r.getQueryStringParamStr("two"));
+ BOOST_REQUIRE_EQUAL("3", *r.getQueryStringParamStr("three"));
}
BOOST_AUTO_TEST_CASE(requestmethod_get)
@@ -218,14 +218,14 @@ BOOST_AUTO_TEST_CASE(requestmethod_missing)
BOOST_AUTO_TEST_CASE(acceptheader)
{
TestRequest r(this, {{"SCRIPT_NAME=/", "HTTP_ACCEPT=text/html"}});
- BOOST_REQUIRE_EQUAL("text/html", *r.getHeaderParam("ACCEPT"));
- BOOST_REQUIRE_EQUAL("text/html", *r.getHeaderParam(IceSpider::H::ACCEPT));
+ BOOST_REQUIRE_EQUAL("text/html", *r.getHeaderParamStr("ACCEPT"));
+ BOOST_REQUIRE_EQUAL("text/html", *r.getHeaderParamStr(IceSpider::H::ACCEPT));
}
BOOST_AUTO_TEST_CASE(missingheader)
{
TestRequest r(this, {{"SCRIPT_NAME=/", "HTTP_ACCEPT=text/html"}});
- BOOST_REQUIRE(!r.getHeaderParam("ACCEPT_LANGUAGE"));
+ BOOST_REQUIRE(!r.getHeaderParamStr("ACCEPT_LANGUAGE"));
}
BOOST_AUTO_TEST_CASE(postxwwwformurlencoded_simple)
diff --git a/icespider/unittests/testPerf.cpp b/icespider/unittests/testPerf.cpp
index a349b54..b23f436 100644
--- a/icespider/unittests/testPerf.cpp
+++ b/icespider/unittests/testPerf.cpp
@@ -71,7 +71,7 @@ BENCHMARK_F(CoreFixture, get_env_param)(benchmark::State & state)
CharPtrPtrArray env(rootDir / "fixtures/env1");
TestRequest r(this, env);
for (auto _ : state) {
- benchmark::DoNotOptimize(r.getEnv("REMOTE_PORT"));
+ benchmark::DoNotOptimize(r.getEnvStr("REMOTE_PORT"));
}
}
@@ -80,7 +80,7 @@ BENCHMARK_F(CoreFixture, get_header_param)(benchmark::State & state)
CharPtrPtrArray env(rootDir / "fixtures/env1");
TestRequest r(this, env);
for (auto _ : state) {
- benchmark::DoNotOptimize(r.getHeaderParam("user_agent"));
+ benchmark::DoNotOptimize(r.getHeaderParamStr("user_agent"));
}
}
@@ -89,7 +89,7 @@ BENCHMARK_F(CoreFixture, get_query_string_param)(benchmark::State & state)
CharPtrPtrArray env(rootDir / "fixtures/env1");
TestRequest r(this, env);
for (auto _ : state) {
- benchmark::DoNotOptimize(r.getQueryStringParam("utm_source"));
+ benchmark::DoNotOptimize(r.getQueryStringParamStr("utm_source"));
}
}
@@ -98,7 +98,7 @@ BENCHMARK_F(CoreFixture, get_cookie_param)(benchmark::State & state)
CharPtrPtrArray env(rootDir / "fixtures/env1");
TestRequest r(this, env);
for (auto _ : state) {
- benchmark::DoNotOptimize(r.getQueryStringParam("utm_source"));
+ benchmark::DoNotOptimize(r.getQueryStringParamStr("utm_source"));
}
}