Chromium Code Reviews| Index: net/base/upload_data_stream.cc |
| diff --git a/net/base/upload_data_stream.cc b/net/base/upload_data_stream.cc |
| index 9f7bdbb419a28d63610b9235c0d5fcd9a6b5952e..4a056f43557b6da1f316bbce3661cf47f4cedcb9 100644 |
| --- a/net/base/upload_data_stream.cc |
| +++ b/net/base/upload_data_stream.cc |
| @@ -12,6 +12,8 @@ |
| namespace net { |
| +bool UploadDataStream::merge_chunks_ = true; |
| + |
| UploadDataStream::~UploadDataStream() { |
| } |
| @@ -69,8 +71,13 @@ int UploadDataStream::FillBuf() { |
| size_t bytes_copied = std::min(count, size_remaining); |
| - memcpy(buf_->data() + buf_len_, &d[next_element_offset_], bytes_copied); |
| - buf_len_ += bytes_copied; |
| + // Check if we have anything to copy first, because we are getting the |
| + // address of an element in |d| and that will throw an exception if |d| |
| + // is an empty vector. |
| + if (bytes_copied) { |
| + memcpy(buf_->data() + buf_len_, &d[next_element_offset_], bytes_copied); |
| + buf_len_ += bytes_copied; |
| + } |
| if (bytes_copied == count) { |
| advance_to_next_element = true; |
| @@ -126,6 +133,9 @@ int UploadDataStream::FillBuf() { |
| next_element_remaining_ = 0; |
| next_element_stream_.reset(); |
| } |
| + |
| + if (is_chunked() && !merge_chunks_) |
| + break; |
| } |
| if (next_element_ == elements.size() && !buf_len_) { |
| @@ -138,4 +148,13 @@ int UploadDataStream::FillBuf() { |
| return OK; |
| } |
| +bool UploadDataStream::IsOnLastChunk() const { |
| + const std::vector<UploadData::Element>& elements = *data_->elements(); |
| + DCHECK(data_->is_chunked()); |
| + return (eof_ || |
| + (!elements.empty() && |
| + next_element_ == elements.size() && |
|
willchan no longer on Chromium
2011/03/03 23:42:32
What's going on here? Did we catch a bug? It's not
Satish
2011/03/03 23:50:59
Sorry I missed this. Yes I found a bug when testin
|
| + elements.back().is_last_chunk())); |
| +} |
| + |
| } // namespace net |