From a882ab9e89fe4edcc85f1418095ab864bd244d48 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Wed, 7 Jan 2009 17:30:30 +0000 Subject: Allow copying an HTTPResponse so that it can be returned by S3Client methods. --- lib/httpserver/HTTPResponse.h | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) (limited to 'lib/httpserver') 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 Header; -public: void SetResponseCode(int Code); int GetResponseCode() { return mResponseCode; } void SetContentType(const char *ContentType); -- cgit v1.2.3