Index: net/http/http_transaction_unittest.cc |
=================================================================== |
--- net/http/http_transaction_unittest.cc (revision 152798) |
+++ net/http/http_transaction_unittest.cc (working copy) |
@@ -27,6 +27,7 @@ |
// mock transaction data |
const MockTransaction kSimpleGET_Transaction = { |
+ net::OK, |
"http://www.google.com/", |
"GET", |
base::Time(), |
@@ -42,6 +43,7 @@ |
}; |
const MockTransaction kSimplePOST_Transaction = { |
+ net::OK, |
"http://bugdatabase.com/edit", |
"POST", |
base::Time(), |
@@ -57,6 +59,7 @@ |
}; |
const MockTransaction kTypicalGET_Transaction = { |
+ net::OK, |
"http://www.example.com/~foo/bar.html", |
"GET", |
base::Time(), |
@@ -73,6 +76,7 @@ |
}; |
const MockTransaction kETagGET_Transaction = { |
+ net::OK, |
"http://www.google.com/foopy", |
"GET", |
base::Time(), |
@@ -89,6 +93,7 @@ |
}; |
const MockTransaction kRangeGET_Transaction = { |
+ net::OK, |
"http://www.google.com/", |
"GET", |
base::Time(), |
@@ -126,6 +131,9 @@ |
} |
void AddMockTransaction(const MockTransaction* trans) { |
+ // To return a result asynchronously, set the TEST_MODE_SYNC_NET_START bit |
+ // of |test_mode|. |
+ ASSERT_NE(net::ERR_IO_PENDING, trans->start_result); |
mock_transactions[GURL(trans->url).spec()] = trans; |
} |
@@ -230,35 +238,38 @@ |
if (!t) |
return net::ERR_FAILED; |
- std::string resp_status = t->status; |
- std::string resp_headers = t->response_headers; |
- std::string resp_data = t->data; |
- if (t->handler) |
- (t->handler)(request, &resp_status, &resp_headers, &resp_data); |
+ net::Error result = t->start_result; |
+ test_mode_ = t->test_mode; |
+ if (result == net::OK) { |
+ std::string resp_status = t->status; |
+ std::string resp_headers = t->response_headers; |
+ std::string resp_data = t->data; |
+ if (t->handler) |
+ (t->handler)(request, &resp_status, &resp_headers, &resp_data); |
- std::string header_data = base::StringPrintf( |
- "%s\n%s\n", resp_status.c_str(), resp_headers.c_str()); |
- std::replace(header_data.begin(), header_data.end(), '\n', '\0'); |
+ std::string header_data = base::StringPrintf( |
+ "%s\n%s\n", resp_status.c_str(), resp_headers.c_str()); |
+ std::replace(header_data.begin(), header_data.end(), '\n', '\0'); |
- response_.request_time = base::Time::Now(); |
- if (!t->request_time.is_null()) |
- response_.request_time = t->request_time; |
+ response_.request_time = base::Time::Now(); |
+ if (!t->request_time.is_null()) |
+ response_.request_time = t->request_time; |
- response_.was_cached = false; |
+ response_.was_cached = false; |
- response_.response_time = base::Time::Now(); |
- if (!t->response_time.is_null()) |
- response_.response_time = t->response_time; |
+ response_.response_time = base::Time::Now(); |
+ if (!t->response_time.is_null()) |
+ response_.response_time = t->response_time; |
- response_.headers = new net::HttpResponseHeaders(header_data); |
- response_.ssl_info.cert_status = t->cert_status; |
- data_ = resp_data; |
- test_mode_ = t->test_mode; |
+ response_.headers = new net::HttpResponseHeaders(header_data); |
+ response_.ssl_info.cert_status = t->cert_status; |
+ data_ = resp_data; |
+ } |
if (test_mode_ & TEST_MODE_SYNC_NET_START) |
- return net::OK; |
+ return result; |
- CallbackLater(callback, net::OK); |
+ CallbackLater(callback, result); |
return net::ERR_IO_PENDING; |
} |