diff options
author | Chris Wilson <chris+github@qwirx.com> | 2009-01-07 17:30:30 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2009-01-07 17:30:30 +0000 |
commit | a882ab9e89fe4edcc85f1418095ab864bd244d48 (patch) | |
tree | 6b43c2615fafd0680ec6e7f3fa8d89eb4311bf73 /lib/httpserver/HTTPResponse.h | |
parent | 07c938a4c7ffcc7049ee4139dce736d672ad030c (diff) |
Allow copying an HTTPResponse so that it can be returned by S3Client
methods.
Diffstat (limited to 'lib/httpserver/HTTPResponse.h')
-rw-r--r-- | lib/httpserver/HTTPResponse.h | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/lib/httpserver/HTTPResponse.h b/lib/httpserver/HTTPResponse.h index 07838cb0..f3d16eef 100644 --- a/lib/httpserver/HTTPResponse.h +++ b/lib/httpserver/HTTPResponse.h @@ -32,13 +32,35 @@ public: HTTPResponse(); ~HTTPResponse(); -private: - // no copying - HTTPResponse(const HTTPResponse &); - HTTPResponse &operator=(const HTTPResponse &); + // allow copying, but be very careful with the response stream, + // you can only read it once! (this class doesn't police it). + HTTPResponse(const HTTPResponse& rOther) + : mResponseCode(rOther.mResponseCode), + mResponseIsDynamicContent(rOther.mResponseIsDynamicContent), + mKeepAlive(rOther.mKeepAlive), + mContentType(rOther.mContentType), + mExtraHeaders(rOther.mExtraHeaders), + mContentLength(rOther.mContentLength), + mpStreamToSendTo(rOther.mpStreamToSendTo) + { + Write(rOther.GetBuffer(), rOther.GetSize()); + } + + HTTPResponse &operator=(const HTTPResponse &rOther) + { + Write(rOther.GetBuffer(), rOther.GetSize()); + mResponseCode = rOther.mResponseCode; + mResponseIsDynamicContent = rOther.mResponseIsDynamicContent; + mKeepAlive = rOther.mKeepAlive; + mContentType = rOther.mContentType; + mExtraHeaders = rOther.mExtraHeaders; + mContentLength = rOther.mContentLength; + mpStreamToSendTo = rOther.mpStreamToSendTo; + return *this; + } + typedef std::pair<std::string, std::string> Header; -public: void SetResponseCode(int Code); int GetResponseCode() { return mResponseCode; } void SetContentType(const char *ContentType); |