summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/httpserver/testhttpserver.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/httpserver/testhttpserver.cpp b/test/httpserver/testhttpserver.cpp
index 105c17d9..5b608591 100644
--- a/test/httpserver/testhttpserver.cpp
+++ b/test/httpserver/testhttpserver.cpp
@@ -347,6 +347,8 @@ class S3Client
{ }
HTTPResponse GetObject(const std::string& rObjectURI);
+ HTTPResponse PutObject(const std::string& rObjectURI,
+ IOStream& rStreamToSend, const char* pContentType = NULL);
private:
S3Simulator* mpSimulator;
@@ -369,6 +371,13 @@ HTTPResponse S3Client::GetObject(const std::string& rObjectURI)
return FinishAndSendRequest(HTTPRequest::Method_GET, rObjectURI);
}
+HTTPResponse S3Client::PutObject(const std::string& rObjectURI,
+ IOStream& rStreamToSend, const char* pContentType)
+{
+ return FinishAndSendRequest(HTTPRequest::Method_PUT, rObjectURI,
+ &rStreamToSend, pContentType);
+}
+
HTTPResponse S3Client::FinishAndSendRequest(HTTPRequest::Method Method,
const std::string& rRequestURI, IOStream* pStreamToSend,
const char* pStreamContentType)
@@ -683,8 +692,24 @@ int test(int argc, const char *argv[])
response.GetSize());
TEST_EQUAL("omgpuppies!\n", response_data);
+ // make sure that assigning to HTTPResponse does clear stream
+ response = client.GetObject("/photos/puppy.jpg");
+ TEST_EQUAL(200, response.GetResponseCode());
+ response_data = std::string((const char *)response.GetBuffer(),
+ response.GetSize());
+ TEST_EQUAL("omgpuppies!\n", response_data);
+
response = client.GetObject("/nonexist");
TEST_EQUAL(404, response.GetResponseCode());
+
+ FileStream fs("testfiles/testrequests.pl");
+ response = client.PutObject("/newfile", fs);
+ TEST_EQUAL(200, response.GetResponseCode());
+
+ response = client.GetObject("/newfile");
+ TEST_EQUAL(200, response.GetResponseCode());
+ TEST_THAT(fs.CompareWith(response));
+ TEST_EQUAL(0, ::unlink("testfiles/newfile"));
}
{