30#if defined _MSC_VER && _MSC_VER<1900
31#define snprintf _snprintf
48 std::string cacheControl;
52 std::string responseBody;
55 std::string contentDisposition;
74 void setMimeType(
const std::string& m ) { mimeType =
"Content-Type: " + m; };
79 void setLastModified(
const std::string& m ) { modified =
"Last-Modified: " + m; };
85 contentDisposition =
"Content-Disposition: " + type +
"; filename=\"" + name +
"\"";
125 void setError(
const std::string& code,
const std::string& arg );
133 "Access-Control-Allow-Origin: " + c + eof +
134 "Access-Control-Allow-Methods: GET, POST, OPTIONS" + eof +
135 "Access-Control-Allow-Headers: Accept, Content-Type, X-Requested-With, If-Modified-Since" + eof +
136 "Access-Control-Max-Age: 86400";
147 void setCacheControl(
const std::string& c ){ cacheControl =
"Cache-Control: " + c; };
166 void setStatus(
const std::string& s ){ status =
"Status: " + s; }
175 if( error.length() || responseBody.length() || protocol.length() )
return true;
182 if( error.length() )
return true;
205 std::string
createHTTPHeader(
const std::string& mimeType,
const std::string& timeStamp,
unsigned int contentLength=0 );
Class to handle non-image IIP responses including errors.
Definition: IIPResponse.h:40
bool cachable()
Is response cachable?
Definition: IIPResponse.h:157
std::string getAdvert()
Display our advertising banner ;-)
void setStatus(const std::string &s)
Set HTTP status code.
Definition: IIPResponse.h:166
void setCORS(const std::string &c)
Set CORS setting.
Definition: IIPResponse.h:130
bool imageSent()
Indicate whether a response has been sent.
Definition: IIPResponse.h:192
bool errorIsSet()
Indicate whether we have an error message.
Definition: IIPResponse.h:181
void addResponse(const char *c, int a, int b)
Add a response string.
void addResponse(const char *c, int a)
Add a response string.
void setError(const std::string &code, const std::string &arg)
Set an error.
void setMimeType(const std::string &m)
Set the Mime Type.
Definition: IIPResponse.h:74
bool isSet()
Indicate whether this object has had any arguments passed to it.
Definition: IIPResponse.h:174
IIPResponse()
Constructor.
void addResponse(const char *c)
Add a response string.
void addResponse(std::string c, const std::string &a)
Add a response string.
void setCacheControl(const std::string &c)
Set Cache-Control value.
Definition: IIPResponse.h:147
void setLastModified(const std::string &m)
Set the Last Modified header.
Definition: IIPResponse.h:79
void setImageSent()
Set the sent flag indicating that some sort of response has been sent.
Definition: IIPResponse.h:188
void setProtocol(const std::string &p)
Set the IIP protocol version.
Definition: IIPResponse.h:69
std::string getCORS()
Get CORS setting.
Definition: IIPResponse.h:142
std::string getCacheControl()
Get Cache-Control value.
Definition: IIPResponse.h:161
void setContentDisposition(const std::string &name, const std::string &type="inline")
Set Content Disposition header.
Definition: IIPResponse.h:84
void setCachability(bool cachable)
Set whether the response should be cached.
Definition: IIPResponse.h:152
std::string createHTTPHeader(const std::string &mimeType, const std::string &timeStamp, unsigned int contentLength=0)
Convenience function to generate HTTP header fields.
void addResponse(const std::string &r)
Add a response string.
std::string formatResponse()
Get a formatted string to send back.