diff options
| author | Dan Goodliffe <dan@randomdan.homeip.net> | 2018-03-03 01:51:05 +0000 | 
|---|---|---|
| committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2018-03-03 01:51:05 +0000 | 
| commit | 8e51dd38df59ffae44eaa0d12712bf0d05c7880e (patch) | |
| tree | a5f01ee7835198e5dc0276c5f97262aa36481542 | |
| parent | Default 500 error handler (diff) | |
| download | icespider-8e51dd38df59ffae44eaa0d12712bf0d05c7880e.tar.bz2 icespider-8e51dd38df59ffae44eaa0d12712bf0d05c7880e.tar.xz icespider-8e51dd38df59ffae44eaa0d12712bf0d05c7880e.zip  | |
Standard header formattericespider-0.2.3.1
Use CTFs in common library for formatting header output.
| -rw-r--r-- | icespider/common/formatters.h | 12 | ||||
| -rw-r--r-- | icespider/fcgi/cgiRequestBase.cpp | 8 | ||||
| -rw-r--r-- | icespider/testing/testRequest.cpp | 7 | 
3 files changed, 18 insertions, 9 deletions
diff --git a/icespider/common/formatters.h b/icespider/common/formatters.h new file mode 100644 index 0000000..1ec6a6b --- /dev/null +++ b/icespider/common/formatters.h @@ -0,0 +1,12 @@ +#ifndef ICESPIDER_COMMON_FORMATTERS_H +#define ICESPIDER_COMMON_FORMATTERS_H + +#include <compileTimeFormatter.h> + +namespace IceSpider { +	AdHocFormatter(StatusFmt, "Status: %? %?\r\n\r\n"); +	AdHocFormatter(HdrFmt, "%?: %?\r\n"); +} + +#endif + diff --git a/icespider/fcgi/cgiRequestBase.cpp b/icespider/fcgi/cgiRequestBase.cpp index 3b03440..74f1d1f 100644 --- a/icespider/fcgi/cgiRequestBase.cpp +++ b/icespider/fcgi/cgiRequestBase.cpp @@ -6,7 +6,7 @@  #include <util.h>  #include <slicer/modelPartsTypes.h>  #include <slicer/common.h> -#include <compileTimeFormatter.h> +#include <formatters.h>  namespace ba = boost::algorithm; @@ -190,15 +190,13 @@ namespace IceSpider {  	void CgiRequestBase::response(short statusCode, const std::string & statusMsg) const  	{ -		getOutputStream() -			<< "Status: " << statusCode << " " << statusMsg << "\r\n" -			<< "\r\n"; +		StatusFmt::write(getOutputStream(), statusCode, statusMsg);  	}  	void  	CgiRequestBase::setHeader(const std::string & header, const std::string & value) const  	{ -		getOutputStream() << header << ": " << value << "\r\n"; +		HdrFmt::write(getOutputStream(), header, value);  	}  	bool diff --git a/icespider/testing/testRequest.cpp b/icespider/testing/testRequest.cpp index e101dfd..c7fe4d3 100644 --- a/icespider/testing/testRequest.cpp +++ b/icespider/testing/testRequest.cpp @@ -1,6 +1,7 @@  #include "testRequest.h"  #include <boost/algorithm/string/split.hpp>  #include <boost/algorithm/string/classification.hpp> +#include <formatters.h>  namespace IceSpider {  	TestRequest::TestRequest(const Core * c, HttpMethod m, const std::string & p) : @@ -114,15 +115,13 @@ namespace IceSpider {  	void  	TestRequest::response(short statusCode, const std::string & statusMsg) const  	{ -		getOutputStream() -			<< "Status: " << statusCode << " " << statusMsg << "\r\n" -			<< "\r\n"; +		StatusFmt::write(getOutputStream(), statusCode, statusMsg);  	}  	void  	TestRequest::setHeader(const std::string & header, const std::string & value) const  	{ -		getOutputStream() << header << ": " << value << "\r\n"; +		HdrFmt::write(getOutputStream(), header, value);  	}  	std::ostream &  | 
