diff options
| author | Dan Goodliffe <dan@randomdan.homeip.net> | 2017-01-30 16:21:12 +0000 | 
|---|---|---|
| committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2017-01-30 16:21:12 +0000 | 
| commit | 8fa60a19cfe0a7c6c375c1da30f022a5b20a7175 (patch) | |
| tree | f1d87da71f1bc12321a3fde793e71bc5254a5975 | |
| parent | Support for plugable error handlers (diff) | |
| download | icespider-8fa60a19cfe0a7c6c375c1da30f022a5b20a7175.tar.bz2 icespider-8fa60a19cfe0a7c6c375c1da30f022a5b20a7175.tar.xz icespider-8fa60a19cfe0a7c6c375c1da30f022a5b20a7175.zip | |
Dump request details to stderr in case of unhandled exceptionicespider-0.2
| -rw-r--r-- | icespider/core/core.cpp | 2 | ||||
| -rw-r--r-- | icespider/core/ihttpRequest.h | 2 | ||||
| -rw-r--r-- | icespider/fcgi/cgiRequestBase.cpp | 31 | ||||
| -rw-r--r-- | icespider/fcgi/cgiRequestBase.h | 2 | ||||
| -rw-r--r-- | icespider/testing/testRequest.cpp | 6 | ||||
| -rw-r--r-- | icespider/testing/testRequest.h | 1 | 
6 files changed, 44 insertions, 0 deletions
| diff --git a/icespider/core/core.cpp b/icespider/core/core.cpp index 3b3ec06..a822366 100644 --- a/icespider/core/core.cpp +++ b/icespider/core/core.cpp @@ -74,6 +74,7 @@ namespace IceSpider {  		}  		catch (...) {  			request->response(500, "Unknown internal server error"); +			request->dump(std::cerr);  		}  	} @@ -102,6 +103,7 @@ namespace IceSpider {  			}  		}  		request->response(500, exception.what()); +		request->dump(std::cerr);  	}  	Ice::ObjectPrx diff --git a/icespider/core/ihttpRequest.h b/icespider/core/ihttpRequest.h index b22406d..b46477f 100644 --- a/icespider/core/ihttpRequest.h +++ b/icespider/core/ihttpRequest.h @@ -42,6 +42,8 @@ namespace IceSpider {  			virtual std::ostream & getOutputStream() const = 0;  			virtual void setHeader(const std::string &, const std::string &) const = 0; +			virtual std::ostream & dump(std::ostream & s) const = 0; +  			template<typename T>  			T getURLParam(unsigned int) const;  			template<typename T> diff --git a/icespider/fcgi/cgiRequestBase.cpp b/icespider/fcgi/cgiRequestBase.cpp index f99bbf1..3b03440 100644 --- a/icespider/fcgi/cgiRequestBase.cpp +++ b/icespider/fcgi/cgiRequestBase.cpp @@ -6,9 +6,16 @@  #include <util.h>  #include <slicer/modelPartsTypes.h>  #include <slicer/common.h> +#include <compileTimeFormatter.h>  namespace ba = boost::algorithm; +namespace std { +	ostream & operator<<(ostream & s, const IceSpider::CgiRequestBase::Env & e) { +		return s.write(std::get<0>(e), std::get<1>(e) - std::get<0>(e)); +	} +} +  namespace IceSpider {  	CgiRequestBase::CgiRequestBase(Core * c, char ** env) :  		IHttpRequest(c) @@ -59,6 +66,30 @@ namespace IceSpider {  		}  	} +	AdHocFormatter(VarFmt, "\t%?: [%?]\n"); +	AdHocFormatter(PathFmt, "\t[%?]\n"); +	std::ostream & +	CgiRequestBase::dump(std::ostream & s) const +	{ +		s << "Environment dump" << std::endl; +		for (const auto & e : envmap) { +			VarFmt::write(s, e.first, e.second); +		} +		s << "Path dump" << std::endl; +		for (const auto & e : pathElements) { +			PathFmt::write(s, e); +		} +		s << "Query string dump" << std::endl; +		for (const auto & v : qsmap) { +			VarFmt::write(s, v.first, v.second); +		} +		s << "Cookie dump" << std::endl; +		for (const auto & c : cookiemap) { +			VarFmt::write(s, c.first, c.second); +		} +		return s; +	} +  	OptionalString  	CgiRequestBase::optionalLookup(const std::string & key, const VarMap & vm)  	{ diff --git a/icespider/fcgi/cgiRequestBase.h b/icespider/fcgi/cgiRequestBase.h index a7cc27d..808dd35 100644 --- a/icespider/fcgi/cgiRequestBase.h +++ b/icespider/fcgi/cgiRequestBase.h @@ -36,6 +36,8 @@ namespace IceSpider {  			void response(short, const std::string &) const override;  			void setHeader(const std::string &, const std::string &) const override; +			std::ostream & dump(std::ostream & s) const override; +  		private:  			static OptionalString optionalLookup(const std::string & key, const VarMap &);  			static OptionalString optionalLookup(const std::string & key, const StringMap &); diff --git a/icespider/testing/testRequest.cpp b/icespider/testing/testRequest.cpp index daecc49..e101dfd 100644 --- a/icespider/testing/testRequest.cpp +++ b/icespider/testing/testRequest.cpp @@ -125,6 +125,12 @@ namespace IceSpider {  		getOutputStream() << header << ": " << value << "\r\n";  	} +	std::ostream & +	TestRequest::dump(std::ostream & s) const +	{ +		return s; +	} +  	const TestRequest::MapVars &  	TestRequest::getResponseHeaders()  	{ diff --git a/icespider/testing/testRequest.h b/icespider/testing/testRequest.h index 3278930..9e510db 100644 --- a/icespider/testing/testRequest.h +++ b/icespider/testing/testRequest.h @@ -26,6 +26,7 @@ namespace IceSpider {  			std::ostream & getOutputStream() const override;  			void response(short statusCode, const std::string & statusMsg) const override;  			void setHeader(const std::string & header, const std::string & value) const override; +			std::ostream & dump(std::ostream & s) const override;  			const MapVars & getResponseHeaders(); | 
