| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "platform/network/HTTPParsers.h" | 5 #include "platform/network/HTTPParsers.h" |
| 6 | 6 |
| 7 #include "platform/heap/Handle.h" | 7 #include "platform/heap/Handle.h" |
| 8 #include "platform/network/ResourceResponse.h" | 8 #include "platform/network/ResourceResponse.h" |
| 9 #include "platform/weborigin/Suborigin.h" | 9 #include "platform/weborigin/Suborigin.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 AtomicString("text/html , text/plain"))); | 187 AtomicString("text/html , text/plain"))); |
| 188 EXPECT_EQ(textHtml, extractMIMETypeFromMediaType( | 188 EXPECT_EQ(textHtml, extractMIMETypeFromMediaType( |
| 189 AtomicString("text/html\t,\ttext/plain"))); | 189 AtomicString("text/html\t,\ttext/plain"))); |
| 190 EXPECT_EQ(textHtml, extractMIMETypeFromMediaType(AtomicString( | 190 EXPECT_EQ(textHtml, extractMIMETypeFromMediaType(AtomicString( |
| 191 "text/html,text/plain;charset=iso-8859-1"))); | 191 "text/html,text/plain;charset=iso-8859-1"))); |
| 192 | 192 |
| 193 // Preserves case. | 193 // Preserves case. |
| 194 EXPECT_EQ("tExt/hTMl", | 194 EXPECT_EQ("tExt/hTMl", |
| 195 extractMIMETypeFromMediaType(AtomicString("tExt/hTMl"))); | 195 extractMIMETypeFromMediaType(AtomicString("tExt/hTMl"))); |
| 196 | 196 |
| 197 EXPECT_EQ(emptyString(), | 197 EXPECT_EQ(emptyString, |
| 198 extractMIMETypeFromMediaType(AtomicString(", text/html"))); | 198 extractMIMETypeFromMediaType(AtomicString(", text/html"))); |
| 199 EXPECT_EQ(emptyString(), | 199 EXPECT_EQ(emptyString, |
| 200 extractMIMETypeFromMediaType(AtomicString("; text/html"))); | 200 extractMIMETypeFromMediaType(AtomicString("; text/html"))); |
| 201 | 201 |
| 202 // If no normalization is required, the same AtomicString should be returned. | 202 // If no normalization is required, the same AtomicString should be returned. |
| 203 const AtomicString& passthrough = extractMIMETypeFromMediaType(textHtml); | 203 const AtomicString& passthrough = extractMIMETypeFromMediaType(textHtml); |
| 204 EXPECT_EQ(textHtml.impl(), passthrough.impl()); | 204 EXPECT_EQ(textHtml.impl(), passthrough.impl()); |
| 205 } | 205 } |
| 206 | 206 |
| 207 TEST(HTTPParsersTest, ExtractMIMETypeFromMediaTypeInvalidInput) { | 207 TEST(HTTPParsersTest, ExtractMIMETypeFromMediaTypeInvalidInput) { |
| 208 // extractMIMETypeFromMediaType() returns the string before the first | 208 // extractMIMETypeFromMediaType() returns the string before the first |
| 209 // semicolon after trimming OWSes at the head and the tail even if the | 209 // semicolon after trimming OWSes at the head and the tail even if the |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 parseMultipartHeadersFromBody(data, strlen(data), &response, &end); | 494 parseMultipartHeadersFromBody(data, strlen(data), &response, &end); |
| 495 | 495 |
| 496 EXPECT_TRUE(result); | 496 EXPECT_TRUE(result); |
| 497 EXPECT_EQ(strlen(data), end); | 497 EXPECT_EQ(strlen(data), end); |
| 498 EXPECT_EQ("text/html; charset=utf-8", | 498 EXPECT_EQ("text/html; charset=utf-8", |
| 499 response.httpHeaderField("content-type")); | 499 response.httpHeaderField("content-type")); |
| 500 EXPECT_EQ("utf-8", response.textEncodingName()); | 500 EXPECT_EQ("utf-8", response.textEncodingName()); |
| 501 } | 501 } |
| 502 | 502 |
| 503 } // namespace blink | 503 } // namespace blink |
| OLD | NEW |