diff options
author | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-11 19:03:01 +0000 |
---|---|---|
committer | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-11 19:03:01 +0000 |
commit | 762d2db5d5e1b0d7852ddb2efef982b00e897322 (patch) | |
tree | 82056cf164237d4e033dbe8ae4dc1fe093923fb6 /net/url_request/url_request_unittest.cc | |
parent | 72b3e889a6c7a48957de81156487a1dcd6e0201c (diff) | |
download | chromium_src-762d2db5d5e1b0d7852ddb2efef982b00e897322.zip chromium_src-762d2db5d5e1b0d7852ddb2efef982b00e897322.tar.gz chromium_src-762d2db5d5e1b0d7852ddb2efef982b00e897322.tar.bz2 |
Support the PUT HTTP verb in ChromeFrame in the IE host network stack implementation. This verb is supported
in the Chrome network stack.
Added a urlrequest test for the HTTP PUT verb and corresponding support in the HTTP test server.
Fixes bug http://code.google.com/p/chromium/issues/detail?id=31629
Bug=31629
Test=Covered by net tests.
Review URL: http://codereview.chromium.org/538012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35922 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/url_request/url_request_unittest.cc')
-rw-r--r-- | net/url_request/url_request_unittest.cc | 90 |
1 files changed, 49 insertions, 41 deletions
diff --git a/net/url_request/url_request_unittest.cc b/net/url_request/url_request_unittest.cc index 5e9f253..9936643 100644 --- a/net/url_request/url_request_unittest.cc +++ b/net/url_request/url_request_unittest.cc @@ -102,6 +102,51 @@ class URLRequestTestHTTP : public URLRequestTest { server_ = NULL; } + void HTTPUploadDataOperationTest(const std::string& method) { + ASSERT_TRUE(NULL != server_.get()); + const int kMsgSize = 20000; // multiple of 10 + const int kIterations = 50; + char *uploadBytes = new char[kMsgSize+1]; + char *ptr = uploadBytes; + char marker = 'a'; + for (int idx = 0; idx < kMsgSize/10; idx++) { + memcpy(ptr, "----------", 10); + ptr += 10; + if (idx % 100 == 0) { + ptr--; + *ptr++ = marker; + if (++marker > 'z') + marker = 'a'; + } + } + uploadBytes[kMsgSize] = '\0'; + + scoped_refptr<URLRequestContext> context = new URLRequestTestContext(); + + for (int i = 0; i < kIterations; ++i) { + TestDelegate d; + URLRequest r(server_->TestServerPage("echo"), &d); + r.set_context(context); + r.set_method(method.c_str()); + + r.AppendBytesToUpload(uploadBytes, kMsgSize); + + r.Start(); + EXPECT_TRUE(r.is_pending()); + + MessageLoop::current()->Run(); + + ASSERT_EQ(1, d.response_started_count()) << "request failed: " << + (int) r.status().status() << ", os error: " << r.status().os_error(); + + EXPECT_FALSE(d.received_data_before_response()); + EXPECT_EQ(uploadBytes, d.data_received()); + EXPECT_EQ(memcmp(uploadBytes, d.data_received().c_str(), kMsgSize), 0); + EXPECT_EQ(d.data_received().compare(uploadBytes), 0); + } + delete[] uploadBytes; + } + static scoped_refptr<HTTPTestServer> server_; }; @@ -484,48 +529,11 @@ TEST_F(URLRequestTestHTTP, CancelTest5) { } TEST_F(URLRequestTestHTTP, PostTest) { - ASSERT_TRUE(NULL != server_.get()); - const int kMsgSize = 20000; // multiple of 10 - const int kIterations = 50; - char *uploadBytes = new char[kMsgSize+1]; - char *ptr = uploadBytes; - char marker = 'a'; - for (int idx = 0; idx < kMsgSize/10; idx++) { - memcpy(ptr, "----------", 10); - ptr += 10; - if (idx % 100 == 0) { - ptr--; - *ptr++ = marker; - if (++marker > 'z') - marker = 'a'; - } - } - uploadBytes[kMsgSize] = '\0'; - - scoped_refptr<URLRequestContext> context = new URLRequestTestContext(); - - for (int i = 0; i < kIterations; ++i) { - TestDelegate d; - URLRequest r(server_->TestServerPage("echo"), &d); - r.set_context(context); - r.set_method("POST"); - - r.AppendBytesToUpload(uploadBytes, kMsgSize); - - r.Start(); - EXPECT_TRUE(r.is_pending()); - - MessageLoop::current()->Run(); - - ASSERT_EQ(1, d.response_started_count()) << "request failed: " << - (int) r.status().status() << ", os error: " << r.status().os_error(); + HTTPUploadDataOperationTest("POST"); +} - EXPECT_FALSE(d.received_data_before_response()); - EXPECT_EQ(uploadBytes, d.data_received()); - EXPECT_EQ(memcmp(uploadBytes, d.data_received().c_str(), kMsgSize), 0); - EXPECT_EQ(d.data_received().compare(uploadBytes), 0); - } - delete[] uploadBytes; +TEST_F(URLRequestTestHTTP, PutTest) { + HTTPUploadDataOperationTest("PUT"); } TEST_F(URLRequestTestHTTP, PostEmptyTest) { |