Index: net/server/http_server_unittest.cc |
diff --git a/net/server/http_server_unittest.cc b/net/server/http_server_unittest.cc |
index 87c35b198e7b3d42d385681aedc576a3766e09d0..2dab596ef67b22ea6a270a17b2b9b902e751afdb 100644 |
--- a/net/server/http_server_unittest.cc |
+++ b/net/server/http_server_unittest.cc |
@@ -91,12 +91,21 @@ class TestHttpClient { |
} |
bool Read(std::string* message) { |
- net::TestCompletionCallback callback; |
- ReadInternal(callback.callback()); |
- int bytes_received = callback.WaitForResult(); |
- if (bytes_received <= 0) |
- return false; |
- *message = std::string(read_buffer_->data(), bytes_received); |
+ return Read(message, 1); |
+ } |
+ |
+ bool Read(std::string* message, int expected_bytes) { |
+ int total_bytes_received = 0; |
mef
2014/04/23 21:46:03
do you need to clear a |message| here?
gunsch
2014/04/24 20:02:47
Done.
|
+ while (total_bytes_received < expected_bytes) { |
+ net::TestCompletionCallback callback; |
+ ReadInternal(callback.callback()); |
+ int bytes_received = callback.WaitForResult(); |
+ if (bytes_received <= 0) |
+ return false; |
+ |
+ total_bytes_received += bytes_received; |
+ message->append(read_buffer_->data(), bytes_received); |
+ } |
return true; |
} |
@@ -308,8 +317,7 @@ TEST_F(HttpServerTest, Send200) { |
ASSERT_TRUE(EndsWith(response, "Response!", true)); |
} |
-// Flaky on at least OS X and Vista. http://crbug.com/365067. |
-TEST_F(HttpServerTest, DISABLED_SendRaw) { |
+TEST_F(HttpServerTest, SendRaw) { |
TestHttpClient client; |
ASSERT_EQ(OK, client.ConnectAndWait(server_address_)); |
client.Send("GET /test HTTP/1.1\r\n\r\n"); |
@@ -319,7 +327,7 @@ TEST_F(HttpServerTest, DISABLED_SendRaw) { |
server_->SendRaw(GetConnectionId(0), "Third Piece of Data"); |
std::string response; |
- ASSERT_TRUE(client.Read(&response)); |
+ ASSERT_TRUE(client.Read(&response, 37)); |
mef
2014/04/23 21:46:03
How was this magical number calculated?
gunsch
2014/04/24 20:02:47
Done.
|
ASSERT_EQ("Raw Data More DataThird Piece of Data", response); |
} |