| OLD | NEW |
| 1 // Copyright 2014 The Crashpad Authors. All rights reserved. | 1 // Copyright 2014 The Crashpad Authors. All rights reserved. |
| 2 // | 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
| 5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
| 6 // | 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // | 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 base::FilePath("util/net/testdata/ascii_http_body.txt"), "text/plain"); | 103 base::FilePath("util/net/testdata/ascii_http_body.txt"), "text/plain"); |
| 104 builder.SetFileAttachment("\"third 50% silly\"", "test%foo.txt", | 104 builder.SetFileAttachment("\"third 50% silly\"", "test%foo.txt", |
| 105 base::FilePath("util/net/testdata/ascii_http_body.txt"), "text/plain"); | 105 base::FilePath("util/net/testdata/ascii_http_body.txt"), "text/plain"); |
| 106 | 106 |
| 107 const char kFileContents[] = "This is a test.\n"; | 107 const char kFileContents[] = "This is a test.\n"; |
| 108 | 108 |
| 109 scoped_ptr<HTTPBodyStream> body(builder.GetBodyStream()); | 109 scoped_ptr<HTTPBodyStream> body(builder.GetBodyStream()); |
| 110 ASSERT_TRUE(body.get()); | 110 ASSERT_TRUE(body.get()); |
| 111 std::string contents = ReadStreamToString(body.get()); | 111 std::string contents = ReadStreamToString(body.get()); |
| 112 auto lines = SplitCRLF(contents); | 112 auto lines = SplitCRLF(contents); |
| 113 ASSERT_EQ(16u, lines.size()); |
| 113 auto lines_it = lines.begin(); | 114 auto lines_it = lines.begin(); |
| 114 | 115 |
| 115 const std::string& boundary = *lines_it++; | 116 const std::string& boundary = *lines_it++; |
| 116 EXPECT_GE(boundary.length(), 1u); | 117 EXPECT_GE(boundary.length(), 1u); |
| 117 EXPECT_LE(boundary.length(), 70u); | 118 EXPECT_LE(boundary.length(), 70u); |
| 118 | 119 |
| 119 EXPECT_EQ("Content-Disposition: form-data; " | 120 EXPECT_EQ("Content-Disposition: form-data; " |
| 120 "name=\"%22third 50%25 silly%22\"; filename=\"test%25foo.txt\"", | 121 "name=\"%22third 50%25 silly%22\"; filename=\"test%25foo.txt\"", |
| 121 *lines_it++); | 122 *lines_it++); |
| 122 EXPECT_EQ("Content-Type: text/plain", *lines_it++); | 123 EXPECT_EQ("Content-Type: text/plain", *lines_it++); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 builder.SetFileAttachment("minidump", "minidump.dmp", | 178 builder.SetFileAttachment("minidump", "minidump.dmp", |
| 178 base::FilePath("util/net/testdata/binary_http_body.dat"), ""); | 179 base::FilePath("util/net/testdata/binary_http_body.dat"), ""); |
| 179 builder.SetFileAttachment("minidump2", "minidump.dmp", | 180 builder.SetFileAttachment("minidump2", "minidump.dmp", |
| 180 base::FilePath("util/net/testdata/binary_http_body.dat"), ""); | 181 base::FilePath("util/net/testdata/binary_http_body.dat"), ""); |
| 181 builder.SetFileAttachment("minidump", "minidump.dmp", | 182 builder.SetFileAttachment("minidump", "minidump.dmp", |
| 182 base::FilePath("util/net/testdata/ascii_http_body.txt"), "text/plain"); | 183 base::FilePath("util/net/testdata/ascii_http_body.txt"), "text/plain"); |
| 183 scoped_ptr<HTTPBodyStream> body(builder.GetBodyStream()); | 184 scoped_ptr<HTTPBodyStream> body(builder.GetBodyStream()); |
| 184 ASSERT_TRUE(body.get()); | 185 ASSERT_TRUE(body.get()); |
| 185 std::string contents = ReadStreamToString(body.get()); | 186 std::string contents = ReadStreamToString(body.get()); |
| 186 auto lines = SplitCRLF(contents); | 187 auto lines = SplitCRLF(contents); |
| 188 ASSERT_EQ(15u, lines.size()); |
| 187 auto lines_it = lines.begin(); | 189 auto lines_it = lines.begin(); |
| 188 | 190 |
| 189 const std::string& boundary = *lines_it++; | 191 const std::string& boundary = *lines_it++; |
| 190 EXPECT_GE(boundary.length(), 1u); | 192 EXPECT_GE(boundary.length(), 1u); |
| 191 EXPECT_LE(boundary.length(), 70u); | 193 EXPECT_LE(boundary.length(), 70u); |
| 192 | 194 |
| 193 EXPECT_EQ("Content-Disposition: form-data; name=\"a key\"", *lines_it++); | 195 EXPECT_EQ("Content-Disposition: form-data; name=\"a key\"", *lines_it++); |
| 194 EXPECT_EQ("", *lines_it++); | 196 EXPECT_EQ("", *lines_it++); |
| 195 EXPECT_EQ(kValue, *lines_it++); | 197 EXPECT_EQ(kValue, *lines_it++); |
| 196 | 198 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 ASSERT_DEATH(builder.SetFileAttachment("", "", base::FilePath(), "<>"), ""); | 259 ASSERT_DEATH(builder.SetFileAttachment("", "", base::FilePath(), "<>"), ""); |
| 258 // Invalid but safe: | 260 // Invalid but safe: |
| 259 builder.SetFileAttachment("", "", base::FilePath(), "0/totally/-invalid.pdf"); | 261 builder.SetFileAttachment("", "", base::FilePath(), "0/totally/-invalid.pdf"); |
| 260 // Valid and safe: | 262 // Valid and safe: |
| 261 builder.SetFileAttachment("", "", base::FilePath(), "application/xml+xhtml"); | 263 builder.SetFileAttachment("", "", base::FilePath(), "application/xml+xhtml"); |
| 262 } | 264 } |
| 263 | 265 |
| 264 } // namespace | 266 } // namespace |
| 265 } // namespace test | 267 } // namespace test |
| 266 } // namespace crashpad | 268 } // namespace crashpad |
| OLD | NEW |