| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/http/http_transaction_unittest.h" | 5 #include "net/http/http_transaction_unittest.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 "GET", | 30 "GET", |
| 31 base::Time(), | 31 base::Time(), |
| 32 "", | 32 "", |
| 33 net::LOAD_NORMAL, | 33 net::LOAD_NORMAL, |
| 34 "HTTP/1.1 200 OK", | 34 "HTTP/1.1 200 OK", |
| 35 "Cache-Control: max-age=10000\n", | 35 "Cache-Control: max-age=10000\n", |
| 36 base::Time(), | 36 base::Time(), |
| 37 "<html><body>Google Blah Blah</body></html>", | 37 "<html><body>Google Blah Blah</body></html>", |
| 38 TEST_MODE_NORMAL, | 38 TEST_MODE_NORMAL, |
| 39 NULL, | 39 NULL, |
| 40 0 | 40 0, |
| 41 string16() |
| 41 }; | 42 }; |
| 42 | 43 |
| 43 const MockTransaction kSimplePOST_Transaction = { | 44 const MockTransaction kSimplePOST_Transaction = { |
| 44 "http://bugdatabase.com/edit", | 45 "http://bugdatabase.com/edit", |
| 45 "POST", | 46 "POST", |
| 46 base::Time(), | 47 base::Time(), |
| 47 "", | 48 "", |
| 48 net::LOAD_NORMAL, | 49 net::LOAD_NORMAL, |
| 49 "HTTP/1.1 200 OK", | 50 "HTTP/1.1 200 OK", |
| 50 "", | 51 "", |
| 51 base::Time(), | 52 base::Time(), |
| 52 "<html><body>Google Blah Blah</body></html>", | 53 "<html><body>Google Blah Blah</body></html>", |
| 53 TEST_MODE_NORMAL, | 54 TEST_MODE_NORMAL, |
| 54 NULL, | 55 NULL, |
| 55 0 | 56 0, |
| 57 string16() |
| 56 }; | 58 }; |
| 57 | 59 |
| 58 const MockTransaction kTypicalGET_Transaction = { | 60 const MockTransaction kTypicalGET_Transaction = { |
| 59 "http://www.example.com/~foo/bar.html", | 61 "http://www.example.com/~foo/bar.html", |
| 60 "GET", | 62 "GET", |
| 61 base::Time(), | 63 base::Time(), |
| 62 "", | 64 "", |
| 63 net::LOAD_NORMAL, | 65 net::LOAD_NORMAL, |
| 64 "HTTP/1.1 200 OK", | 66 "HTTP/1.1 200 OK", |
| 65 "Date: Wed, 28 Nov 2007 09:40:09 GMT\n" | 67 "Date: Wed, 28 Nov 2007 09:40:09 GMT\n" |
| 66 "Last-Modified: Wed, 28 Nov 2007 00:40:09 GMT\n", | 68 "Last-Modified: Wed, 28 Nov 2007 00:40:09 GMT\n", |
| 67 base::Time(), | 69 base::Time(), |
| 68 "<html><body>Google Blah Blah</body></html>", | 70 "<html><body>Google Blah Blah</body></html>", |
| 69 TEST_MODE_NORMAL, | 71 TEST_MODE_NORMAL, |
| 70 NULL, | 72 NULL, |
| 71 0 | 73 0, |
| 74 string16() |
| 72 }; | 75 }; |
| 73 | 76 |
| 74 const MockTransaction kETagGET_Transaction = { | 77 const MockTransaction kETagGET_Transaction = { |
| 75 "http://www.google.com/foopy", | 78 "http://www.google.com/foopy", |
| 76 "GET", | 79 "GET", |
| 77 base::Time(), | 80 base::Time(), |
| 78 "", | 81 "", |
| 79 net::LOAD_NORMAL, | 82 net::LOAD_NORMAL, |
| 80 "HTTP/1.1 200 OK", | 83 "HTTP/1.1 200 OK", |
| 81 "Cache-Control: max-age=10000\n" | 84 "Cache-Control: max-age=10000\n" |
| 82 "Etag: foopy\n", | 85 "Etag: foopy\n", |
| 83 base::Time(), | 86 base::Time(), |
| 84 "<html><body>Google Blah Blah</body></html>", | 87 "<html><body>Google Blah Blah</body></html>", |
| 85 TEST_MODE_NORMAL, | 88 TEST_MODE_NORMAL, |
| 86 NULL, | 89 NULL, |
| 87 0 | 90 0, |
| 91 string16() |
| 88 }; | 92 }; |
| 89 | 93 |
| 90 const MockTransaction kRangeGET_Transaction = { | 94 const MockTransaction kRangeGET_Transaction = { |
| 91 "http://www.google.com/", | 95 "http://www.google.com/", |
| 92 "GET", | 96 "GET", |
| 93 base::Time(), | 97 base::Time(), |
| 94 "Range: 0-100\r\n", | 98 "Range: 0-100\r\n", |
| 95 net::LOAD_NORMAL, | 99 net::LOAD_NORMAL, |
| 96 "HTTP/1.1 200 OK", | 100 "HTTP/1.1 200 OK", |
| 97 "Cache-Control: max-age=10000\n", | 101 "Cache-Control: max-age=10000\n", |
| 98 base::Time(), | 102 base::Time(), |
| 99 "<html><body>Google Blah Blah</body></html>", | 103 "<html><body>Google Blah Blah</body></html>", |
| 100 TEST_MODE_NORMAL, | 104 TEST_MODE_NORMAL, |
| 101 NULL, | 105 NULL, |
| 102 0 | 106 0, |
| 107 string16() |
| 103 }; | 108 }; |
| 104 | 109 |
| 105 static const MockTransaction* const kBuiltinMockTransactions[] = { | 110 static const MockTransaction* const kBuiltinMockTransactions[] = { |
| 106 &kSimpleGET_Transaction, | 111 &kSimpleGET_Transaction, |
| 107 &kSimplePOST_Transaction, | 112 &kSimplePOST_Transaction, |
| 108 &kTypicalGET_Transaction, | 113 &kTypicalGET_Transaction, |
| 109 &kETagGET_Transaction, | 114 &kETagGET_Transaction, |
| 110 &kRangeGET_Transaction | 115 &kRangeGET_Transaction |
| 111 }; | 116 }; |
| 112 | 117 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 response_.request_time = t->request_time; | 245 response_.request_time = t->request_time; |
| 241 | 246 |
| 242 response_.was_cached = false; | 247 response_.was_cached = false; |
| 243 | 248 |
| 244 response_.response_time = base::Time::Now(); | 249 response_.response_time = base::Time::Now(); |
| 245 if (!t->response_time.is_null()) | 250 if (!t->response_time.is_null()) |
| 246 response_.response_time = t->response_time; | 251 response_.response_time = t->response_time; |
| 247 | 252 |
| 248 response_.headers = new net::HttpResponseHeaders(header_data); | 253 response_.headers = new net::HttpResponseHeaders(header_data); |
| 249 response_.ssl_info.cert_status = t->cert_status; | 254 response_.ssl_info.cert_status = t->cert_status; |
| 255 response_.ssl_info.tls_username = t->tls_username; |
| 250 data_ = resp_data; | 256 data_ = resp_data; |
| 251 test_mode_ = t->test_mode; | 257 test_mode_ = t->test_mode; |
| 252 | 258 |
| 253 if (test_mode_ & TEST_MODE_SYNC_NET_START) | 259 if (test_mode_ & TEST_MODE_SYNC_NET_START) |
| 254 return net::OK; | 260 return net::OK; |
| 255 | 261 |
| 256 CallbackLater(callback, net::OK); | 262 CallbackLater(callback, net::OK); |
| 257 return net::ERR_IO_PENDING; | 263 return net::ERR_IO_PENDING; |
| 258 } | 264 } |
| 259 | 265 |
| 260 int MockNetworkTransaction::RestartIgnoringLastError( | 266 int MockNetworkTransaction::RestartIgnoringLastError( |
| 261 net::CompletionCallback* callback) { | 267 net::CompletionCallback* callback) { |
| 262 return net::ERR_FAILED; | 268 return net::ERR_FAILED; |
| 263 } | 269 } |
| 264 | 270 |
| 265 int MockNetworkTransaction::RestartWithCertificate( | 271 int MockNetworkTransaction::RestartWithCertificate( |
| 266 net::X509Certificate* client_cert, | 272 net::X509Certificate* client_cert, |
| 267 net::CompletionCallback* callback) { | 273 net::CompletionCallback* callback) { |
| 268 return net::ERR_FAILED; | 274 return net::ERR_FAILED; |
| 269 } | 275 } |
| 270 | 276 |
| 277 void MockNetworkTransaction::SetTLSLoginAuthData(net::AuthData* auth_data) { |
| 278 } |
| 279 |
| 280 int MockNetworkTransaction::RestartWithTLSLogin( |
| 281 net::CompletionCallback* callback) { |
| 282 return net::ERR_FAILED; |
| 283 } |
| 284 |
| 271 int MockNetworkTransaction::RestartWithAuth(const string16& username, | 285 int MockNetworkTransaction::RestartWithAuth(const string16& username, |
| 272 const string16& password, | 286 const string16& password, |
| 273 net::CompletionCallback* callback) { | 287 net::CompletionCallback* callback) { |
| 274 return net::ERR_FAILED; | 288 return net::ERR_FAILED; |
| 275 } | 289 } |
| 276 | 290 |
| 277 bool MockNetworkTransaction::IsReadyToRestartForAuth() { | 291 bool MockNetworkTransaction::IsReadyToRestartForAuth() { |
| 278 return false; | 292 return false; |
| 279 } | 293 } |
| 280 | 294 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 if (rv > 0) { | 372 if (rv > 0) { |
| 359 content.append(buf->data(), rv); | 373 content.append(buf->data(), rv); |
| 360 } else if (rv < 0) { | 374 } else if (rv < 0) { |
| 361 return rv; | 375 return rv; |
| 362 } | 376 } |
| 363 } while (rv > 0); | 377 } while (rv > 0); |
| 364 | 378 |
| 365 result->swap(content); | 379 result->swap(content); |
| 366 return net::OK; | 380 return net::OK; |
| 367 } | 381 } |
| OLD | NEW |