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

Unified 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 12 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/glue/multipart_response_delegate.cc ('k') | webkit/glue/webkit_glue.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/glue/multipart_response_delegate_unittest.cc
===================================================================
--- webkit/glue/multipart_response_delegate_unittest.cc (revision 7355)
+++ webkit/glue/multipart_response_delegate_unittest.cc (working copy)
@@ -225,7 +225,33 @@
client.data_);
}
+TEST(MultipartResponseTest, MalformedBoundary) {
+ // Some servers send a boundary that is prefixed by "--". See bug 5786.
+ ResourceResponse response(KURL(), "multipart/x-mixed-replace", 0, "en-US",
+ String());
+ response.setHTTPHeaderField(String("Foo"), String("Bar"));
+ response.setHTTPHeaderField(String("Content-type"), String("text/plain"));
+ MockResourceHandleClient client;
+ MultipartResponseDelegate delegate(&client, NULL, response, "--bound");
+
+ string data(
+ "--bound\n"
+ "Content-type: text/plain\n\n"
+ "This is a sample response\n"
+ "--bound--"
+ "ignore junk after end token --bound\n\nTest2\n");
+ 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_);
+
+ delegate.OnCompletedRequest();
+ EXPECT_EQ(1, client.received_response_);
+ EXPECT_EQ(1, client.received_data_);
+}
+
+
// Used in for tests that break the data in various places.
struct TestChunk {
const int start_pos; // offset in data
« 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