diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2017-01-30 14:08:36 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2017-01-30 14:08:36 +0000 |
commit | b7de6028c797177e8d8411f080307cc9faf936af (patch) | |
tree | 96837e1b5a2d7ec0b28a487b66e5cbf598d2e023 /icespider/testing/testRequest.cpp | |
parent | Fix case where operation returns void but has declared exception list (return... (diff) | |
download | icespider-b7de6028c797177e8d8411f080307cc9faf936af.tar.bz2 icespider-b7de6028c797177e8d8411f080307cc9faf936af.tar.xz icespider-b7de6028c797177e8d8411f080307cc9faf936af.zip |
Support for plugable error handlers
Diffstat (limited to 'icespider/testing/testRequest.cpp')
-rw-r--r-- | icespider/testing/testRequest.cpp | 67 |
1 files changed, 58 insertions, 9 deletions
diff --git a/icespider/testing/testRequest.cpp b/icespider/testing/testRequest.cpp index 1645445..daecc49 100644 --- a/icespider/testing/testRequest.cpp +++ b/icespider/testing/testRequest.cpp @@ -14,40 +14,89 @@ namespace IceSpider { } } - const std::vector<std::string> & + const PathElements & TestRequest::getRequestPath() const { return url; } + PathElements & + TestRequest::getRequestPath() + { + return url; + } + HttpMethod TestRequest::getRequestMethod() const { return method; } - IceUtil::Optional<std::string> + OptionalString TestRequest::getEnv(const std::string & key) const { - return env.find(key) == env.end() ? IceUtil::Optional<std::string>() : env.find(key)->second; + return get(key, env); } - IceUtil::Optional<std::string> + OptionalString TestRequest::getQueryStringParam(const std::string & key) const { - return qs.find(key) == qs.end() ? IceUtil::Optional<std::string>() : qs.find(key)->second; + return get(key, qs); } - IceUtil::Optional<std::string> + OptionalString TestRequest::getCookieParam(const std::string & key) const { - return cookies.find(key) == cookies.end() ? IceUtil::Optional<std::string>() : cookies.find(key)->second; + return get(key, cookies); } - IceUtil::Optional<std::string> + OptionalString TestRequest::getHeaderParam(const std::string & key) const { - return hdr.find(key) == hdr.end() ? IceUtil::Optional<std::string>() : hdr.find(key)->second; + return get(key, hdr); + } + + OptionalString + TestRequest::get(const std::string & key, const MapVars & vars) const + { + auto i = vars.find(key); + if (i == vars.end()) { + return IceUtil::None; + } + return i->second; + } + + void + TestRequest::setQueryStringParam(const std::string & key, const OptionalString & val) + { + set(key, val, qs); + } + + void + TestRequest::setHeaderParam(const std::string & key, const OptionalString & val) + { + set(key, val, hdr); + } + + void + TestRequest::setCookieParam(const std::string & key, const OptionalString & val) + { + set(key, val, cookies); + } + + void + TestRequest::setEnv(const std::string & key, const OptionalString & val) + { + set(key, val, env); + } + + void + TestRequest::set(const std::string & key, const OptionalString & val, MapVars & vars) + { + if (val) + vars[key] = *val; + else + vars.erase(key); } std::istream & |