summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2009-01-09 10:19:46 +0000
committerChris Wilson <chris+github@qwirx.com>2009-01-09 10:19:46 +0000
commit0b999ceba3550774ef00dc0170c6995b353bb791 (patch)
tree97f781d37ac2314a7be5f76ee4ea3f3dd05de752
parent1c712f9e709f40914412f7368e4945226b45a879 (diff)
Add support for PUT requests in HTTP simulator.
-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"));
}
{