Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(613)

Side by Side Diff: net/http/http_util_unittest.cc

Issue 1374883002: Add UMAs for checking header values against RFC 7230 in //net (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use StringPiece. Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <algorithm> 5 #include <algorithm>
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "net/http/http_util.h" 9 #include "net/http/http_util.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 1160 matching lines...) Expand 10 before | Expand all | Expand 10 after
1171 std::string data = "name='value"; 1171 std::string data = "name='value";
1172 HttpUtil::NameValuePairsIterator parser(data.begin(), data.end(), ';'); 1172 HttpUtil::NameValuePairsIterator parser(data.begin(), data.end(), ';');
1173 EXPECT_TRUE(parser.valid()); 1173 EXPECT_TRUE(parser.valid());
1174 1174
1175 ASSERT_NO_FATAL_FAILURE( 1175 ASSERT_NO_FATAL_FAILURE(
1176 CheckNextNameValuePair(&parser, true, true, "name", "value")); 1176 CheckNextNameValuePair(&parser, true, true, "name", "value"));
1177 ASSERT_NO_FATAL_FAILURE(CheckNextNameValuePair( 1177 ASSERT_NO_FATAL_FAILURE(CheckNextNameValuePair(
1178 &parser, false, true, std::string(), std::string())); 1178 &parser, false, true, std::string(), std::string()));
1179 } 1179 }
1180 1180
1181 TEST(HttpUtilTest, IsValidHeaderValueRFC7230) {
1182 EXPECT_TRUE(HttpUtil::IsValidHeaderValueRFC7230(""));
1183
1184 EXPECT_FALSE(HttpUtil::IsValidHeaderValueRFC7230(" "));
1185 EXPECT_FALSE(HttpUtil::IsValidHeaderValueRFC7230(" q"));
1186 EXPECT_FALSE(HttpUtil::IsValidHeaderValueRFC7230("q "));
1187 EXPECT_FALSE(HttpUtil::IsValidHeaderValueRFC7230("\t"));
1188 EXPECT_FALSE(HttpUtil::IsValidHeaderValueRFC7230("\tq"));
1189 EXPECT_FALSE(HttpUtil::IsValidHeaderValueRFC7230("q\t"));
1190
1191 EXPECT_TRUE(HttpUtil::IsValidHeaderValueRFC7230("q q"));
1192 EXPECT_TRUE(HttpUtil::IsValidHeaderValueRFC7230("q\tq"));
1193
1194 EXPECT_FALSE(HttpUtil::IsValidHeaderValueRFC7230(std::string("\0", 1)));
1195 EXPECT_FALSE(HttpUtil::IsValidHeaderValueRFC7230(std::string("q\0q", 3)));
1196 EXPECT_FALSE(HttpUtil::IsValidHeaderValueRFC7230("q\rq"));
1197 EXPECT_FALSE(HttpUtil::IsValidHeaderValueRFC7230("q\nq"));
1198 EXPECT_FALSE(HttpUtil::IsValidHeaderValueRFC7230("q\x01q"));
1199 EXPECT_FALSE(HttpUtil::IsValidHeaderValueRFC7230("q\x7fq"));
1200
1201 EXPECT_TRUE(HttpUtil::IsValidHeaderValueRFC7230("q\x80q"));
1202 }
1203
1181 } // namespace net 1204 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698