summaryrefslogtreecommitdiffstats
path: root/webkit/glue/multipart_response_delegate_unittest.cc
diff options
context:
space:
mode:
authortony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-13 00:54:47 +0000
committertony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-13 00:54:47 +0000
commit6eca5f19ffabd672349df42595551e7a4b1da987 (patch)
treec9f2565f1ef32435072aba1dace92de204b58f1d /webkit/glue/multipart_response_delegate_unittest.cc
parent4c9ef951d9d3c32d7955583bba6639efac26362c (diff)
downloadchromium_src-6eca5f19ffabd672349df42595551e7a4b1da987.zip
chromium_src-6eca5f19ffabd672349df42595551e7a4b1da987.tar.gz
chromium_src-6eca5f19ffabd672349df42595551e7a4b1da987.tar.bz2
Fix a bug where we were setting the mime-type to the full
content-type (e.g., text/html; charset=utf-8) in multipart responses. This fixes a bug where e.g., CUPS pages wouldn't be rendered properly. BUG=25217 TEST=Covered by unittests. Review URL: http://codereview.chromium.org/385046 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31867 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/multipart_response_delegate_unittest.cc')
-rw-r--r--webkit/glue/multipart_response_delegate_unittest.cc38
1 files changed, 26 insertions, 12 deletions
diff --git a/webkit/glue/multipart_response_delegate_unittest.cc b/webkit/glue/multipart_response_delegate_unittest.cc
index 5c57265..846f323 100644
--- a/webkit/glue/multipart_response_delegate_unittest.cc
+++ b/webkit/glue/multipart_response_delegate_unittest.cc
@@ -160,18 +160,32 @@ TEST(MultipartResponseTest, Functions) {
delegate_tester.data().assign(test_header);
EXPECT_TRUE(delegate_tester.ParseHeaders());
EXPECT_TRUE(delegate_tester.data().length() == 0);
- EXPECT_EQ(webkit_glue::WebStringToStdString(
- client.response_.httpHeaderField(
- WebString::fromUTF8("Content-Type"))),
- string("image/png"));
- EXPECT_EQ(webkit_glue::WebStringToStdString(
- client.response_.httpHeaderField(
- WebString::fromUTF8("content-length"))),
- string("10"));
+ EXPECT_EQ(string("image/png"),
+ webkit_glue::WebStringToStdString(
+ client.response_.httpHeaderField(
+ WebString::fromUTF8("Content-Type"))));
+ EXPECT_EQ(string("10"),
+ webkit_glue::WebStringToStdString(
+ client.response_.httpHeaderField(
+ WebString::fromUTF8("content-length"))));
// This header is passed from the original request.
- EXPECT_EQ(webkit_glue::WebStringToStdString(
- client.response_.httpHeaderField(WebString::fromUTF8("foo"))),
- string("Bar"));
+ EXPECT_EQ(string("Bar"),
+ webkit_glue::WebStringToStdString(
+ client.response_.httpHeaderField(WebString::fromUTF8("foo"))));
+
+ // Make sure we parse the right mime-type if a charset is provided.
+ client.Reset();
+ string test_header2("content-type: text/html; charset=utf-8\n\n");
+ delegate_tester.data().assign(test_header2);
+ EXPECT_TRUE(delegate_tester.ParseHeaders());
+ EXPECT_TRUE(delegate_tester.data().length() == 0);
+ EXPECT_EQ(string("text/html; charset=utf-8"),
+ webkit_glue::WebStringToStdString(
+ client.response_.httpHeaderField(
+ WebString::fromUTF8("Content-Type"))));
+ EXPECT_EQ(string("utf-8"),
+ webkit_glue::WebStringToStdString(
+ client.response_.textEncodingName()));
// FindBoundary tests
struct {
@@ -247,7 +261,7 @@ TEST(MultipartResponseTest, MissingBoundaries) {
"Content-type: text/plain\n\n"
"This is a sample response\n");
delegate3.OnReceivedData(no_boundaries.c_str(),
- static_cast<int>(no_boundaries.length()));
+ static_cast<int>(no_boundaries.length()));
EXPECT_EQ(1, client.received_response_);
EXPECT_EQ(0, client.received_data_);
EXPECT_EQ(string(), client.data_);