| 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 "base/hash_tables.h" | 7 #include "base/hash_tables.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 //----------------------------------------------------------------------------- | 140 //----------------------------------------------------------------------------- |
| 141 // helpers | 141 // helpers |
| 142 | 142 |
| 143 int ReadTransaction(net::HttpTransaction* trans, std::string* result) { | 143 int ReadTransaction(net::HttpTransaction* trans, std::string* result) { |
| 144 int rv; | 144 int rv; |
| 145 | 145 |
| 146 TestCompletionCallback callback; | 146 TestCompletionCallback callback; |
| 147 | 147 |
| 148 std::string content; | 148 std::string content; |
| 149 do { | 149 do { |
| 150 scoped_refptr<net::IOBuffer> buf = new net::IOBuffer(256); | 150 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(256)); |
| 151 rv = trans->Read(buf, 256, &callback); | 151 rv = trans->Read(buf, 256, &callback); |
| 152 if (rv == net::ERR_IO_PENDING) | 152 if (rv == net::ERR_IO_PENDING) |
| 153 rv = callback.WaitForResult(); | 153 rv = callback.WaitForResult(); |
| 154 if (rv > 0) { | 154 if (rv > 0) { |
| 155 content.append(buf->data(), rv); | 155 content.append(buf->data(), rv); |
| 156 } else if (rv < 0) { | 156 } else if (rv < 0) { |
| 157 return rv; | 157 return rv; |
| 158 } | 158 } |
| 159 } while (rv > 0); | 159 } while (rv > 0); |
| 160 | 160 |
| 161 result->swap(content); | 161 result->swap(content); |
| 162 return net::OK; | 162 return net::OK; |
| 163 } | 163 } |
| OLD | NEW |