summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authorananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-16 02:28:36 +0000
committerananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-16 02:28:36 +0000
commitbeac9998f6cb2de039fa6d49f241ce4e924f05f4 (patch)
treea7977f3ce9bc982ec4287bc4998ba484af68b3d7 /webkit
parentfebe7e1c89d096517f416721f6f98617b30d238c (diff)
downloadchromium_src-beac9998f6cb2de039fa6d49f241ce4e924f05f4.zip
chromium_src-beac9998f6cb2de039fa6d49f241ce4e924f05f4.tar.gz
chromium_src-beac9998f6cb2de039fa6d49f241ce4e924f05f4.tar.bz2
Fix PDF files not loading at times with Acrobat Reader. This only happens in the FastWebView code path while handling
byte range requests. We need to strip out trailing \n\r characters before the boundary marker on the same lines as Firefox. Updated the multipart tests to account for this. Fixes bug http://code.google.com/p/chromium/issues/detail?id=48580 Bug=48580 Review URL: http://codereview.chromium.org/2881017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@52595 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/glue/multipart_response_delegate.cc19
-rw-r--r--webkit/glue/multipart_response_delegate_unittest.cc13
2 files changed, 22 insertions, 10 deletions
diff --git a/webkit/glue/multipart_response_delegate.cc b/webkit/glue/multipart_response_delegate.cc
index d7c8c29..0b37050 100644
--- a/webkit/glue/multipart_response_delegate.cc
+++ b/webkit/glue/multipart_response_delegate.cc
@@ -126,10 +126,21 @@ void MultipartResponseDelegate::OnReceivedData(const char* data,
size_t boundary_pos;
while ((boundary_pos = FindBoundary()) != std::string::npos) {
if (boundary_pos > 0 && client_) {
- // Send the last data chunk.
- client_->didReceiveData(loader_,
- data_.data(),
- static_cast<int>(boundary_pos));
+ // Strip out trailing \n\r characters in the buffer preceding the
+ // boundary on the same lines as Firefox.
+ size_t data_length = boundary_pos;
+ if (data_[boundary_pos - 1] == '\n') {
+ data_length--;
+ if (data_[boundary_pos - 2] == '\r') {
+ data_length--;
+ }
+ }
+ if (data_length > 0) {
+ // Send the last data chunk.
+ client_->didReceiveData(loader_,
+ data_.data(),
+ static_cast<int>(data_length));
+ }
}
size_t boundary_end_pos = boundary_pos + boundary_.length();
if (boundary_end_pos < data_.length() && '-' == data_[boundary_end_pos]) {
diff --git a/webkit/glue/multipart_response_delegate_unittest.cc b/webkit/glue/multipart_response_delegate_unittest.cc
index 84d1e05..0433b52 100644
--- a/webkit/glue/multipart_response_delegate_unittest.cc
+++ b/webkit/glue/multipart_response_delegate_unittest.cc
@@ -221,7 +221,7 @@ TEST(MultipartResponseTest, MissingBoundaries) {
static_cast<int>(no_start_boundary.length()));
EXPECT_EQ(1, client.received_response_);
EXPECT_EQ(1, client.received_data_);
- EXPECT_EQ(string("This is a sample response\n"),
+ EXPECT_EQ(string("This is a sample response"),
client.data_);
delegate.OnCompletedRequest();
@@ -287,7 +287,7 @@ TEST(MultipartResponseTest, MalformedBoundary) {
delegate.OnReceivedData(data.c_str(), static_cast<int>(data.length()));
EXPECT_EQ(1, client.received_response_);
EXPECT_EQ(1, client.received_data_);
- EXPECT_EQ(string("This is a sample response\n"), client.data_);
+ EXPECT_EQ(string("This is a sample response"), client.data_);
delegate.OnCompletedRequest();
EXPECT_EQ(1, client.received_response_);
@@ -304,8 +304,9 @@ struct TestChunk {
const char* expected_data;
};
-void VariousChunkSizesTest(const TestChunk chunks[], int chunks_size, int responses,
- int received_data, const char* completed_data) {
+void VariousChunkSizesTest(const TestChunk chunks[], int chunks_size,
+ int responses, int received_data,
+ const char* completed_data) {
const string data(
"--bound\n" // 0-7
"Content-type: image/png\n\n" // 8-32
@@ -618,7 +619,7 @@ TEST(MultipartResponseTest, MultipartPayloadSet) {
delegate.OnReceivedData(data.c_str(), static_cast<int>(data.length()));
EXPECT_EQ(1,
client.received_response_);
- EXPECT_EQ(string("response data\n"),
+ EXPECT_EQ(string("response data"),
client.data_);
EXPECT_EQ(false, client.response_.isMultipartPayload());
@@ -629,7 +630,7 @@ TEST(MultipartResponseTest, MultipartPayloadSet) {
delegate.OnReceivedData(data2.c_str(), static_cast<int>(data2.length()));
EXPECT_EQ(2,
client.received_response_);
- EXPECT_EQ(string("response data2\n"),
+ EXPECT_EQ(string("response data2"),
client.data_);
EXPECT_EQ(true, client.response_.isMultipartPayload());
}