diff options
author | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-22 19:47:23 +0000 |
---|---|---|
committer | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-22 19:47:23 +0000 |
commit | c90b8b52a75caf8fb695947aeafd8d76030b47b6 (patch) | |
tree | 62ec345bb9fdb8e7682a34eda84211f49473942a /webkit/glue/multipart_response_delegate_unittest.cc | |
parent | 5531c25bf144183612d4bf9f6746a7a682eb7904 (diff) | |
download | chromium_src-c90b8b52a75caf8fb695947aeafd8d76030b47b6.zip chromium_src-c90b8b52a75caf8fb695947aeafd8d76030b47b6.tar.gz chromium_src-c90b8b52a75caf8fb695947aeafd8d76030b47b6.tar.bz2 |
Handle cases where the multipart boundary is improperly prefixed with "--".
The change to webkit_glue::InitializeForTesting is to make it possible to just run the multipart tests using --gtest_filter.
R=tony
BUG=5786
Review URL: http://codereview.chromium.org/16420
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7364 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/multipart_response_delegate_unittest.cc')
-rw-r--r-- | webkit/glue/multipart_response_delegate_unittest.cc | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/webkit/glue/multipart_response_delegate_unittest.cc b/webkit/glue/multipart_response_delegate_unittest.cc index e7d020c..c70f55a 100644 --- a/webkit/glue/multipart_response_delegate_unittest.cc +++ b/webkit/glue/multipart_response_delegate_unittest.cc @@ -225,6 +225,32 @@ TEST(MultipartResponseTest, MissingBoundaries) { 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 { |