[Box Backup-commit] COMMIT r2443 - box/trunk/lib/httpserver

boxbackup-dev at boxbackup.org boxbackup-dev at boxbackup.org
Wed Jan 7 17:30:31 GMT 2009


Author: chris
Date: 2009-01-07 17:30:30 +0000 (Wed, 07 Jan 2009)
New Revision: 2443

Modified:
   box/trunk/lib/httpserver/HTTPResponse.h
Log:
Allow copying an HTTPResponse so that it can be returned by S3Client 
methods.


Modified: box/trunk/lib/httpserver/HTTPResponse.h
===================================================================
--- box/trunk/lib/httpserver/HTTPResponse.h	2009-01-06 13:18:07 UTC (rev 2442)
+++ box/trunk/lib/httpserver/HTTPResponse.h	2009-01-07 17:30:30 UTC (rev 2443)
@@ -32,13 +32,35 @@
 	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);




More information about the Boxbackup-commit mailing list