| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 <windows.h> | |
| 8 | |
| 9 #include "base/hash_tables.h" | 7 #include "base/hash_tables.h" |
| 10 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 11 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 12 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
| 13 #include "net/base/load_flags.h" | 11 #include "net/base/load_flags.h" |
| 14 #include "net/disk_cache/disk_cache.h" | 12 #include "net/disk_cache/disk_cache.h" |
| 15 #include "net/http/http_cache.h" | 13 #include "net/http/http_cache.h" |
| 16 #include "net/http/http_request_info.h" | 14 #include "net/http/http_request_info.h" |
| 17 #include "net/http/http_response_info.h" | 15 #include "net/http/http_response_info.h" |
| 18 #include "net/http/http_transaction.h" | 16 #include "net/http/http_transaction.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 20 | 18 |
| 21 #pragma warning(disable: 4355) | |
| 22 | |
| 23 //----------------------------------------------------------------------------- | 19 //----------------------------------------------------------------------------- |
| 24 // mock transaction data | 20 // mock transaction data |
| 25 | 21 |
| 26 const MockTransaction kSimpleGET_Transaction = { | 22 const MockTransaction kSimpleGET_Transaction = { |
| 27 "http://www.google.com/", | 23 "http://www.google.com/", |
| 28 "GET", | 24 "GET", |
| 29 "", | 25 "", |
| 30 net::LOAD_NORMAL, | 26 net::LOAD_NORMAL, |
| 31 "HTTP/1.1 200 OK", | 27 "HTTP/1.1 200 OK", |
| 32 "Cache-Control: max-age=10000\n", | 28 "Cache-Control: max-age=10000\n", |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 mock_transactions.erase(GURL(trans->url).spec()); | 106 mock_transactions.erase(GURL(trans->url).spec()); |
| 111 } | 107 } |
| 112 | 108 |
| 113 const MockTransaction* FindMockTransaction(const GURL& url) { | 109 const MockTransaction* FindMockTransaction(const GURL& url) { |
| 114 // look for overrides: | 110 // look for overrides: |
| 115 MockTransactionMap::const_iterator it = mock_transactions.find(url.spec()); | 111 MockTransactionMap::const_iterator it = mock_transactions.find(url.spec()); |
| 116 if (it != mock_transactions.end()) | 112 if (it != mock_transactions.end()) |
| 117 return it->second; | 113 return it->second; |
| 118 | 114 |
| 119 // look for builtins: | 115 // look for builtins: |
| 120 for (int i = 0; i < arraysize(kBuiltinMockTransactions); ++i) { | 116 for (size_t i = 0; i < arraysize(kBuiltinMockTransactions); ++i) { |
| 121 if (url == GURL(kBuiltinMockTransactions[i]->url)) | 117 if (url == GURL(kBuiltinMockTransactions[i]->url)) |
| 122 return kBuiltinMockTransactions[i]; | 118 return kBuiltinMockTransactions[i]; |
| 123 } | 119 } |
| 124 return NULL; | 120 return NULL; |
| 125 } | 121 } |
| 126 | 122 |
| 127 | 123 |
| 128 //----------------------------------------------------------------------------- | 124 //----------------------------------------------------------------------------- |
| 129 | 125 |
| 130 // static | 126 // static |
| (...skipping 17 matching lines...) Expand all Loading... |
| 148 if (rv > 0) { | 144 if (rv > 0) { |
| 149 content.append(buf, rv); | 145 content.append(buf, rv); |
| 150 } else if (rv < 0) { | 146 } else if (rv < 0) { |
| 151 return rv; | 147 return rv; |
| 152 } | 148 } |
| 153 } while (rv > 0); | 149 } while (rv > 0); |
| 154 | 150 |
| 155 result->swap(content); | 151 result->swap(content); |
| 156 return net::OK; | 152 return net::OK; |
| 157 } | 153 } |
| OLD | NEW |