Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Side by Side Diff: webkit/glue/multipart_response_delegate_unittest.cc

Issue 16420: Handle cases where the multipart boundary is improperly prefixed with "--".... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/glue/multipart_response_delegate.cc ('k') | webkit/glue/webkit_glue.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <vector> 5 #include <vector>
6 6
7 #include "config.h" 7 #include "config.h"
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 10
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 EXPECT_EQ(0, client.received_data_); 218 EXPECT_EQ(0, client.received_data_);
219 EXPECT_EQ(string(), client.data_); 219 EXPECT_EQ(string(), client.data_);
220 220
221 delegate3.OnCompletedRequest(); 221 delegate3.OnCompletedRequest();
222 EXPECT_EQ(1, client.received_response_); 222 EXPECT_EQ(1, client.received_response_);
223 EXPECT_EQ(1, client.received_data_); 223 EXPECT_EQ(1, client.received_data_);
224 EXPECT_EQ(string("This is a sample response\n"), 224 EXPECT_EQ(string("This is a sample response\n"),
225 client.data_); 225 client.data_);
226 } 226 }
227 227
228 TEST(MultipartResponseTest, MalformedBoundary) {
229 // Some servers send a boundary that is prefixed by "--". See bug 5786.
230
231 ResourceResponse response(KURL(), "multipart/x-mixed-replace", 0, "en-US",
232 String());
233 response.setHTTPHeaderField(String("Foo"), String("Bar"));
234 response.setHTTPHeaderField(String("Content-type"), String("text/plain"));
235 MockResourceHandleClient client;
236 MultipartResponseDelegate delegate(&client, NULL, response, "--bound");
237
238 string data(
239 "--bound\n"
240 "Content-type: text/plain\n\n"
241 "This is a sample response\n"
242 "--bound--"
243 "ignore junk after end token --bound\n\nTest2\n");
244 delegate.OnReceivedData(data.c_str(), static_cast<int>(data.length()));
245 EXPECT_EQ(1, client.received_response_);
246 EXPECT_EQ(1, client.received_data_);
247 EXPECT_EQ(string("This is a sample response\n"), client.data_);
248
249 delegate.OnCompletedRequest();
250 EXPECT_EQ(1, client.received_response_);
251 EXPECT_EQ(1, client.received_data_);
252 }
253
228 254
229 // Used in for tests that break the data in various places. 255 // Used in for tests that break the data in various places.
230 struct TestChunk { 256 struct TestChunk {
231 const int start_pos; // offset in data 257 const int start_pos; // offset in data
232 const int end_pos; // end offset in data 258 const int end_pos; // end offset in data
233 const int expected_responses; 259 const int expected_responses;
234 const int expected_received_data; 260 const int expected_received_data;
235 const char* expected_data; 261 const char* expected_data;
236 }; 262 };
237 263
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 512
487 result = MultipartResponseDelegate::ReadContentRanges( 513 result = MultipartResponseDelegate::ReadContentRanges(
488 response2, &content_range_lower_bound, 514 response2, &content_range_lower_bound,
489 &content_range_upper_bound); 515 &content_range_upper_bound);
490 516
491 EXPECT_EQ(result, false); 517 EXPECT_EQ(result, false);
492 } 518 }
493 519
494 } // namespace 520 } // namespace
495 521
OLDNEW
« no previous file with comments | « webkit/glue/multipart_response_delegate.cc ('k') | webkit/glue/webkit_glue.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698