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

Side by Side Diff: net/quic/spdy_utils.cc

Issue 1878083002: Implement IsAsciiUpper and IsAsciiLower in base/strings/string_util.h (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: git sync Created 4 years, 8 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "net/quic/spdy_utils.h" 5 #include "net/quic/spdy_utils.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
11 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
12 #include "base/strings/string_split.h" 12 #include "base/strings/string_split.h"
13 #include "base/strings/string_util.h"
13 #include "net/spdy/spdy_frame_builder.h" 14 #include "net/spdy/spdy_frame_builder.h"
14 #include "net/spdy/spdy_framer.h" 15 #include "net/spdy/spdy_framer.h"
15 #include "net/spdy/spdy_protocol.h" 16 #include "net/spdy/spdy_protocol.h"
16 #include "url/gurl.h" 17 #include "url/gurl.h"
17 18
18 using std::string; 19 using std::string;
19 using std::vector; 20 using std::vector;
20 21
21 namespace net { 22 namespace net {
22 23
23 bool ascii_isupper(unsigned char c) {
24 return c >= 'A' && c <= 'Z';
25 }
26
27 // static 24 // static
28 string SpdyUtils::SerializeUncompressedHeaders(const SpdyHeaderBlock& headers) { 25 string SpdyUtils::SerializeUncompressedHeaders(const SpdyHeaderBlock& headers) {
29 SpdyMajorVersion spdy_version = HTTP2; 26 SpdyMajorVersion spdy_version = HTTP2;
30 27
31 size_t length = SpdyFramer::GetSerializedLength(spdy_version, &headers); 28 size_t length = SpdyFramer::GetSerializedLength(spdy_version, &headers);
32 SpdyFrameBuilder builder(length, spdy_version); 29 SpdyFrameBuilder builder(length, spdy_version);
33 SpdyFramer framer(spdy_version); 30 SpdyFramer framer(spdy_version);
34 framer.SerializeHeaderBlockWithoutCompression(&builder, headers); 31 framer.SerializeHeaderBlockWithoutCompression(&builder, headers);
35 SpdySerializedFrame block(builder.take()); 32 SpdySerializedFrame block(builder.take());
36 return string(block.data(), length); 33 return string(block.data(), length);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 size_t* final_byte_offset, 112 size_t* final_byte_offset,
116 SpdyHeaderBlock* trailers) { 113 SpdyHeaderBlock* trailers) {
117 for (const auto& p : header_list) { 114 for (const auto& p : header_list) {
118 const string& name = p.first; 115 const string& name = p.first;
119 if (name.empty() || name[0] == ':') { 116 if (name.empty() || name[0] == ':') {
120 DVLOG(1) << "Trailers must not be empty, and must not contain pseudo-" 117 DVLOG(1) << "Trailers must not be empty, and must not contain pseudo-"
121 << "headers. Found: '" << name << "'"; 118 << "headers. Found: '" << name << "'";
122 return false; 119 return false;
123 } 120 }
124 121
125 if (std::any_of(name.begin(), name.end(), ascii_isupper)) { 122 if (std::any_of(name.begin(), name.end(), base::IsAsciiUpper<char>)) {
126 DVLOG(1) << "Malformed header: Header name " << name 123 DVLOG(1) << "Malformed header: Header name " << name
127 << " contains upper-case characters."; 124 << " contains upper-case characters.";
128 return false; 125 return false;
129 } 126 }
130 127
131 if (trailers->find(name) != trailers->end()) { 128 if (trailers->find(name) != trailers->end()) {
132 DVLOG(1) << "Duplicate header '" << name << "' found in trailers."; 129 DVLOG(1) << "Duplicate header '" << name << "' found in trailers.";
133 return false; 130 return false;
134 } 131 }
135 132
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 return GURL(GetUrlFromHeaderBlock(headers)).host(); 183 return GURL(GetUrlFromHeaderBlock(headers)).host();
187 } 184 }
188 185
189 // static 186 // static
190 bool SpdyUtils::UrlIsValid(const SpdyHeaderBlock& headers) { 187 bool SpdyUtils::UrlIsValid(const SpdyHeaderBlock& headers) {
191 string url(GetUrlFromHeaderBlock(headers)); 188 string url(GetUrlFromHeaderBlock(headers));
192 return url != "" && GURL(url).is_valid(); 189 return url != "" && GURL(url).is_valid();
193 } 190 }
194 191
195 } // namespace net 192 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698