summaryrefslogtreecommitdiff
path: root/icespider/testing/testRequest.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2018-05-13 12:00:22 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2019-01-14 20:50:12 +0000
commitf840d002b00288e1bbc30251c9b093026dd540f4 (patch)
tree18251762e25ff4d65086c79972af9436866edde8 /icespider/testing/testRequest.cpp
parentCut 1 string_view (diff)
downloadicespider-f840d002b00288e1bbc30251c9b093026dd540f4.tar.bz2
icespider-f840d002b00288e1bbc30251c9b093026dd540f4.tar.xz
icespider-f840d002b00288e1bbc30251c9b093026dd540f4.zip
Cut 2 string_view
Diffstat (limited to 'icespider/testing/testRequest.cpp')
-rw-r--r--icespider/testing/testRequest.cpp34
1 files changed, 17 insertions, 17 deletions
diff --git a/icespider/testing/testRequest.cpp b/icespider/testing/testRequest.cpp
index c7fe4d3..11fd721 100644
--- a/icespider/testing/testRequest.cpp
+++ b/icespider/testing/testRequest.cpp
@@ -4,7 +4,7 @@
#include <formatters.h>
namespace IceSpider {
- TestRequest::TestRequest(const Core * c, HttpMethod m, const std::string & p) :
+ TestRequest::TestRequest(const Core * c, HttpMethod m, const std::string_view & p) :
IHttpRequest(c),
method(m)
{
@@ -34,31 +34,31 @@ namespace IceSpider {
}
OptionalString
- TestRequest::getEnv(const std::string & key) const
+ TestRequest::getEnv(const std::string_view & key) const
{
return get(key, env);
}
OptionalString
- TestRequest::getQueryStringParam(const std::string & key) const
+ TestRequest::getQueryStringParam(const std::string_view & key) const
{
return get(key, qs);
}
OptionalString
- TestRequest::getCookieParam(const std::string & key) const
+ TestRequest::getCookieParam(const std::string_view & key) const
{
return get(key, cookies);
}
OptionalString
- TestRequest::getHeaderParam(const std::string & key) const
+ TestRequest::getHeaderParam(const std::string_view & key) const
{
return get(key, hdr);
}
OptionalString
- TestRequest::get(const std::string & key, const MapVars & vars) const
+ TestRequest::get(const std::string_view & key, const MapVars & vars) const
{
auto i = vars.find(key);
if (i == vars.end()) {
@@ -68,36 +68,36 @@ namespace IceSpider {
}
void
- TestRequest::setQueryStringParam(const std::string & key, const OptionalString & val)
+ TestRequest::setQueryStringParam(const std::string_view & key, const OptionalString & val)
{
set(key, val, qs);
}
void
- TestRequest::setHeaderParam(const std::string & key, const OptionalString & val)
+ TestRequest::setHeaderParam(const std::string_view & key, const OptionalString & val)
{
set(key, val, hdr);
}
-
+
void
- TestRequest::setCookieParam(const std::string & key, const OptionalString & val)
+ TestRequest::setCookieParam(const std::string_view & key, const OptionalString & val)
{
set(key, val, cookies);
}
void
- TestRequest::setEnv(const std::string & key, const OptionalString & val)
+ TestRequest::setEnv(const std::string_view & key, const OptionalString & val)
{
set(key, val, env);
}
-
+
void
- TestRequest::set(const std::string & key, const OptionalString & val, MapVars & vars)
+ TestRequest::set(const std::string_view & key, const OptionalString & val, MapVars & vars)
{
if (val)
- vars[key] = *val;
+ vars[std::string(key)] = *val;
else
- vars.erase(key);
+ vars.erase(vars.find(key));
}
std::istream &
@@ -113,13 +113,13 @@ namespace IceSpider {
}
void
- TestRequest::response(short statusCode, const std::string & statusMsg) const
+ TestRequest::response(short statusCode, const std::string_view & statusMsg) const
{
StatusFmt::write(getOutputStream(), statusCode, statusMsg);
}
void
- TestRequest::setHeader(const std::string & header, const std::string & value) const
+ TestRequest::setHeader(const std::string_view & header, const std::string_view & value) const
{
HdrFmt::write(getOutputStream(), header, value);
}