Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(718)

Unified Diff: net/url_request/url_request_unittest.cc

Issue 6134003: Prototype of chunked transfer encoded POST. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« net/tools/testserver/testserver.py ('K') | « net/url_request/url_request.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/url_request/url_request_unittest.cc
diff --git a/net/url_request/url_request_unittest.cc b/net/url_request/url_request_unittest.cc
index 82efe662e52dc9a36e45fd6554b34f2791160465..9498b78de30d5c00b4b8920df684dc5314a2c66e 100644
--- a/net/url_request/url_request_unittest.cc
+++ b/net/url_request/url_request_unittest.cc
@@ -638,6 +638,42 @@ TEST_F(URLRequestTestHTTP, PostFileTest) {
}
}
+TEST_F(URLRequestTestHTTP, PostChunkedDataTest) {
vandebo (ex-Chrome) 2011/01/21 18:08:41 If I read this test right, it looks like all the d
Satish 2011/01/21 20:29:57 Makes sense. I could do that in this same test by
+ ASSERT_TRUE(test_server_.Start());
+
+ TestDelegate d;
+ {
+ TestURLRequest r(test_server_.GetURL("echo"), &d);
+ r.EnableChunkedUpload();
+ r.set_method("POST");
+ r.AppendChunkToUpload("a", 1);
vandebo (ex-Chrome) 2011/01/21 18:08:41 I thought you weren't supposed to call AppendChunk
Satish 2011/01/21 20:29:57 Good catch, yes the code is allowing these calls b
vandebo (ex-Chrome) 2011/01/21 20:47:13 Having two tests would yield better test coverage.
+ r.AppendChunkToUpload("bcd", 3);
+
+ r.Start();
+ EXPECT_TRUE(r.is_pending());
+
+ r.AppendChunkToUpload("this is a longer chunk than before.", 35);
+ r.AppendChunkToUpload("\r\n\r\n", 4);
+ r.AppendChunkToUpload("0", 1);
+ r.AppendChunkToUpload("2323", 4);
+ r.MarkEndOfChunks();
+
+ MessageLoop::current()->Run();
+
+ const char* encoded_data =
+ "abcdthis is a longer chunk than before.\r\n\r\n02323";
+
+ 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());
+
+ ASSERT_EQ(strlen(encoded_data), static_cast<size_t>(d.bytes_received()));
+ EXPECT_EQ(0, memcmp(d.data_received().c_str(), encoded_data,
+ strlen(encoded_data)));
+ }
+}
+
TEST_F(URLRequestTest, AboutBlankTest) {
TestDelegate d;
{
« net/tools/testserver/testserver.py ('K') | « net/url_request/url_request.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698