| 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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 //----------------------------------------------------------------------------- | 130 //----------------------------------------------------------------------------- |
| 131 // helpers | 131 // helpers |
| 132 | 132 |
| 133 int ReadTransaction(net::HttpTransaction* trans, std::string* result) { | 133 int ReadTransaction(net::HttpTransaction* trans, std::string* result) { |
| 134 int rv; | 134 int rv; |
| 135 | 135 |
| 136 TestCompletionCallback callback; | 136 TestCompletionCallback callback; |
| 137 | 137 |
| 138 std::string content; | 138 std::string content; |
| 139 do { | 139 do { |
| 140 char buf[256]; | 140 scoped_refptr<net::IOBuffer> buf = new net::IOBuffer(256); |
| 141 rv = trans->Read(buf, sizeof(buf), &callback); | 141 rv = trans->Read(buf, 256, &callback); |
| 142 if (rv == net::ERR_IO_PENDING) | 142 if (rv == net::ERR_IO_PENDING) |
| 143 rv = callback.WaitForResult(); | 143 rv = callback.WaitForResult(); |
| 144 if (rv > 0) { | 144 if (rv > 0) { |
| 145 content.append(buf, rv); | 145 content.append(buf->data(), rv); |
| 146 } else if (rv < 0) { | 146 } else if (rv < 0) { |
| 147 return rv; | 147 return rv; |
| 148 } | 148 } |
| 149 } while (rv > 0); | 149 } while (rv > 0); |
| 150 | 150 |
| 151 result->swap(content); | 151 result->swap(content); |
| 152 return net::OK; | 152 return net::OK; |
| 153 } | 153 } |
| OLD | NEW |