Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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/spdy/spdy_alt_svc_wire_format.h" | 5 #include "net/spdy/spdy_alt_svc_wire_format.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
|
diannahu
2017/03/29 15:42:57
Can this be removed?
Bence
2017/03/29 16:56:18
Unfortunately not: it is needed for base::IsHexDig
xunjieli
2017/03/29 17:43:48
I am still concerned about this approach. Does hav
| |
| 13 #include "base/strings/stringprintf.h" | 13 #include "net/spdy/platform/api/spdy_string_utils.h" |
| 14 | 14 |
| 15 namespace net { | 15 namespace net { |
| 16 | 16 |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 template <class T> | 19 template <class T> |
| 20 bool ParsePositiveIntegerImpl(SpdyStringPiece::const_iterator c, | 20 bool ParsePositiveIntegerImpl(SpdyStringPiece::const_iterator c, |
| 21 SpdyStringPiece::const_iterator end, | 21 SpdyStringPiece::const_iterator end, |
| 22 T* value) { | 22 T* value) { |
| 23 *value = 0; | 23 *value = 0; |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 233 } | 233 } |
| 234 } | 234 } |
| 235 value.push_back('='); | 235 value.push_back('='); |
| 236 value.push_back('"'); | 236 value.push_back('"'); |
| 237 for (char c : altsvc.host) { | 237 for (char c : altsvc.host) { |
| 238 if (c == '"' || c == '\\') { | 238 if (c == '"' || c == '\\') { |
| 239 value.push_back('\\'); | 239 value.push_back('\\'); |
| 240 } | 240 } |
| 241 value.push_back(c); | 241 value.push_back(c); |
| 242 } | 242 } |
| 243 base::StringAppendF(&value, ":%d\"", altsvc.port); | 243 SpdyStringAppendF(&value, ":%d\"", altsvc.port); |
| 244 if (altsvc.max_age != 86400) { | 244 if (altsvc.max_age != 86400) { |
| 245 base::StringAppendF(&value, "; ma=%d", altsvc.max_age); | 245 SpdyStringAppendF(&value, "; ma=%d", altsvc.max_age); |
| 246 } | 246 } |
| 247 if (!altsvc.version.empty()) { | 247 if (!altsvc.version.empty()) { |
| 248 value.append("; v=\""); | 248 value.append("; v=\""); |
| 249 for (VersionVector::const_iterator it = altsvc.version.begin(); | 249 for (VersionVector::const_iterator it = altsvc.version.begin(); |
| 250 it != altsvc.version.end(); ++it) { | 250 it != altsvc.version.end(); ++it) { |
| 251 if (it != altsvc.version.begin()) { | 251 if (it != altsvc.version.begin()) { |
| 252 value.append(","); | 252 value.append(","); |
| 253 } | 253 } |
| 254 base::StringAppendF(&value, "%d", *it); | 254 SpdyStringAppendF(&value, "%d", *it); |
| 255 } | 255 } |
| 256 value.append("\""); | 256 value.append("\""); |
| 257 } | 257 } |
| 258 } | 258 } |
| 259 return value; | 259 return value; |
| 260 } | 260 } |
| 261 | 261 |
| 262 // static | 262 // static |
| 263 void SpdyAltSvcWireFormat::SkipWhiteSpace(SpdyStringPiece::const_iterator* c, | 263 void SpdyAltSvcWireFormat::SkipWhiteSpace(SpdyStringPiece::const_iterator* c, |
| 264 SpdyStringPiece::const_iterator end) { | 264 SpdyStringPiece::const_iterator end) { |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 353 | 353 |
| 354 // static | 354 // static |
| 355 bool SpdyAltSvcWireFormat::ParsePositiveInteger32( | 355 bool SpdyAltSvcWireFormat::ParsePositiveInteger32( |
| 356 SpdyStringPiece::const_iterator c, | 356 SpdyStringPiece::const_iterator c, |
| 357 SpdyStringPiece::const_iterator end, | 357 SpdyStringPiece::const_iterator end, |
| 358 uint32_t* value) { | 358 uint32_t* value) { |
| 359 return ParsePositiveIntegerImpl<uint32_t>(c, end, value); | 359 return ParsePositiveIntegerImpl<uint32_t>(c, end, value); |
| 360 } | 360 } |
| 361 | 361 |
| 362 } // namespace net | 362 } // namespace net |
| OLD | NEW |