summaryrefslogtreecommitdiffstats
path: root/net/http/http_util.cc
diff options
context:
space:
mode:
authorwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-21 18:08:50 +0000
committerwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-21 18:08:50 +0000
commit0b0bf036e2c2722b5d31162ad620b450763fa352 (patch)
treebbeeb3eaaa34df96d3f947d63280a93746837536 /net/http/http_util.cc
parent78859c7d87db4433d068533b104c7c1addf7e7eb (diff)
downloadchromium_src-0b0bf036e2c2722b5d31162ad620b450763fa352.zip
chromium_src-0b0bf036e2c2722b5d31162ad620b450763fa352.tar.gz
chromium_src-0b0bf036e2c2722b5d31162ad620b450763fa352.tar.bz2
Reland r59910 - Add HttpResponseBodyDrainer. Use it for unfinished HttpStreams."
There's one simple fix. wtc had asked me to increment the buffer so we keep reading into new memory while draining the body. So I added |total_read_| to |read_buf_|. The problem is |read_buf_| is an IOBuffer*, not a char*, so I'm causing us to read into raw heap memory. Crashes ensue. My unit tests didn't catch it because they never actually read data. I've fixed that by doing a memset(). I've fixed the problem by not bothering to increment the read index, since that would require throwing away IOBuffers or some intrusive modifications to IOBuffer. BUG=54277 TEST=HttpResponseBodyDrainerTest.* Also see the manual testing instructions in r59910. Review URL: http://codereview.chromium.org/3449014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@60075 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http/http_util.cc')
-rw-r--r--net/http/http_util.cc10
1 files changed, 10 insertions, 0 deletions
diff --git a/net/http/http_util.cc b/net/http/http_util.cc
index 83c17ab..4b52cc3 100644
--- a/net/http/http_util.cc
+++ b/net/http/http_util.cc
@@ -9,11 +9,15 @@
#include <algorithm>
+#include "base/basictypes.h"
#include "base/logging.h"
#include "base/string_number_conversions.h"
#include "base/string_piece.h"
#include "base/string_util.h"
+#include "net/base/net_errors.h"
#include "net/base/net_util.h"
+#include "net/http/http_response_body_drainer.h"
+#include "net/http/http_stream.h"
using std::string;
@@ -695,4 +699,10 @@ bool HttpUtil::ValuesIterator::GetNext() {
return false;
}
+void HttpUtil::DrainStreamBodyAndClose(HttpStream* stream) {
+ HttpResponseBodyDrainer* drainer = new HttpResponseBodyDrainer(stream);
+ drainer->Start();
+ // |drainer| will delete itself.
+}
+
} // namespace net