diff options
| -rw-r--r-- | icespider/fcgi/cgiRequestBase.cpp | 18 | ||||
| -rw-r--r-- | icespider/fcgi/cgiRequestBase.h | 10 | ||||
| -rw-r--r-- | icespider/unittests/testFcgi.cpp | 1 | 
3 files changed, 15 insertions, 14 deletions
diff --git a/icespider/fcgi/cgiRequestBase.cpp b/icespider/fcgi/cgiRequestBase.cpp index 5bcb746..6acaa38 100644 --- a/icespider/fcgi/cgiRequestBase.cpp +++ b/icespider/fcgi/cgiRequestBase.cpp @@ -70,6 +70,11 @@ namespace IceSpider {  		return i->second;  	} +	bool CgiRequestBase::ciLess::operator() (const std::string_view & s1, const std::string_view & s2) const +	{ +		return lexicographical_compare(s1, s2, ba::is_iless()); +	} +  	void  	CgiRequestBase::initialize()  	{ @@ -113,18 +118,9 @@ namespace IceSpider {  		return s;  	} +	template<typename MapType>  	OptionalString -	CgiRequestBase::optionalLookup(const std::string_view & key, const VarMap & vm) -	{ -		auto i = vm.find(key); -		if (i == vm.end()) { -			return {}; -		} -		return i->second; -	} - -	OptionalString -	CgiRequestBase::optionalLookup(const std::string_view & key, const StringMap & vm) +	CgiRequestBase::optionalLookup(const std::string_view & key, const MapType & vm)  	{  		auto i = vm.find(key);  		if (i == vm.end()) { diff --git a/icespider/fcgi/cgiRequestBase.h b/icespider/fcgi/cgiRequestBase.h index 6b430b7..fca2e41 100644 --- a/icespider/fcgi/cgiRequestBase.h +++ b/icespider/fcgi/cgiRequestBase.h @@ -14,7 +14,11 @@ namespace IceSpider {  			void initialize();  		public: +			struct ciLess { +				bool operator()(const std::string_view & s1, const std::string_view & s2) const; +			};  			typedef std::map<std::string_view, const std::string_view> VarMap; +			typedef std::map<std::string_view, const std::string_view, ciLess> HdrMap;  			const PathElements & getRequestPath() const override;  			PathElements & getRequestPath() override; @@ -30,13 +34,13 @@ namespace IceSpider {  			std::ostream & dump(std::ostream & s) const override;  		private: -			static OptionalString optionalLookup(const std::string_view & key, const VarMap &); -			static OptionalString optionalLookup(const std::string_view & key, const StringMap &); +			template<typename MapType> +			static OptionalString optionalLookup(const std::string_view & key, const MapType &);  			VarMap envmap;  			StringMap qsmap;  			StringMap cookiemap; -			VarMap hdrmap; +			HdrMap hdrmap;  			PathElements pathElements;  	};  } diff --git a/icespider/unittests/testFcgi.cpp b/icespider/unittests/testFcgi.cpp index adaaaff..b64dd47 100644 --- a/icespider/unittests/testFcgi.cpp +++ b/icespider/unittests/testFcgi.cpp @@ -232,6 +232,7 @@ BOOST_AUTO_TEST_CASE( acceptheader )  	CharPtrPtrArray env ({ "SCRIPT_NAME=/", "HTTP_ACCEPT=text/html" });  	TestRequest r(this, env);  	BOOST_REQUIRE_EQUAL("text/html", *r.getHeaderParam("ACCEPT")); +	BOOST_REQUIRE_EQUAL("text/html", *r.getHeaderParam(IceSpider::H::ACCEPT));  }  BOOST_AUTO_TEST_CASE( missingheader )  | 
