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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
8 #include "net/base/net_errors.h" | 8 #include "net/base/net_errors.h" |
9 #include "net/http/http_response_headers.h" | 9 #include "net/http/http_response_headers.h" |
10 #include "net/http/http_version.h" | 10 #include "net/http/http_version.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 GURL("bogus"), &mime_type, &charset, &data, headers.get())); | 56 GURL("bogus"), &mime_type, &charset, &data, headers.get())); |
57 } | 57 } |
58 | 58 |
59 TEST(BuildResponseTest, InvalidMimeType) { | 59 TEST(BuildResponseTest, InvalidMimeType) { |
60 std::string mime_type; | 60 std::string mime_type; |
61 std::string charset; | 61 std::string charset; |
62 std::string data; | 62 std::string data; |
63 scoped_refptr<net::HttpResponseHeaders> headers( | 63 scoped_refptr<net::HttpResponseHeaders> headers( |
64 new net::HttpResponseHeaders(std::string())); | 64 new net::HttpResponseHeaders(std::string())); |
65 | 65 |
66 // MIME type contains delimiters. Must be rejected. | 66 // MIME type contains delimiters. Must be accepted but Content-Type header |
| 67 // should not be generated. |
67 EXPECT_EQ( | 68 EXPECT_EQ( |
68 net::ERR_INVALID_URL, | 69 net::OK, |
69 URLRequestDataJob::BuildResponse( | 70 URLRequestDataJob::BuildResponse( |
70 GURL("data:f(o/b)r,test"), | 71 GURL("data:f(o/b)r,test"), |
71 &mime_type, &charset, &data, headers.get())); | 72 &mime_type, &charset, &data, headers.get())); |
| 73 |
| 74 EXPECT_FALSE(headers->HasHeader("Content-Type")); |
72 } | 75 } |
73 | 76 |
74 TEST(BuildResponseTest, InvalidCharset) { | 77 TEST(BuildResponseTest, InvalidCharset) { |
75 std::string mime_type; | 78 std::string mime_type; |
76 std::string charset; | 79 std::string charset; |
77 std::string data; | 80 std::string data; |
78 scoped_refptr<net::HttpResponseHeaders> headers( | 81 scoped_refptr<net::HttpResponseHeaders> headers( |
79 new net::HttpResponseHeaders(std::string())); | 82 new net::HttpResponseHeaders(std::string())); |
80 | 83 |
81 // MIME type contains delimiters. Must be rejected. | 84 // MIME type contains delimiters. Must be rejected. |
82 EXPECT_EQ( | 85 EXPECT_EQ( |
83 net::ERR_INVALID_URL, | 86 net::ERR_INVALID_URL, |
84 URLRequestDataJob::BuildResponse( | 87 URLRequestDataJob::BuildResponse( |
85 GURL("data:text/html;charset=(),test"), | 88 GURL("data:text/html;charset=(),test"), |
86 &mime_type, &charset, &data, headers.get())); | 89 &mime_type, &charset, &data, headers.get())); |
87 } | 90 } |
88 | 91 |
89 } // namespace net | 92 } // namespace net |
OLD | NEW |