| 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 |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 } | 296 } |
| 297 return true; | 297 return true; |
| 298 } | 298 } |
| 299 | 299 |
| 300 // static | 300 // static |
| 301 bool SpdyAltSvcWireFormat::ParseAltAuthority(StringPiece::const_iterator c, | 301 bool SpdyAltSvcWireFormat::ParseAltAuthority(StringPiece::const_iterator c, |
| 302 StringPiece::const_iterator end, | 302 StringPiece::const_iterator end, |
| 303 std::string* host, | 303 std::string* host, |
| 304 uint16_t* port) { | 304 uint16_t* port) { |
| 305 host->clear(); | 305 host->clear(); |
| 306 for (; c != end && *c != ':'; ++c) { | |
| 307 if (*c == '"') { | |
| 308 // Port is mandatory. | |
| 309 return false; | |
| 310 } | |
| 311 if (*c == '\\') { | |
| 312 ++c; | |
| 313 if (c == end) { | |
| 314 return false; | |
| 315 } | |
| 316 } | |
| 317 host->push_back(*c); | |
| 318 } | |
| 319 if (c == end) { | 306 if (c == end) { |
| 320 return false; | 307 return false; |
| 321 } | 308 } |
| 309 if (*c == '[') { |
| 310 for (; c != end && *c != ']'; ++c) { |
| 311 if (*c == '"') { |
| 312 // Port is mandatory. |
| 313 return false; |
| 314 } |
| 315 host->push_back(*c); |
| 316 } |
| 317 if (c == end) { |
| 318 return false; |
| 319 } |
| 320 DCHECK_EQ(']', *c); |
| 321 host->push_back(*c); |
| 322 ++c; |
| 323 } else { |
| 324 for (; c != end && *c != ':'; ++c) { |
| 325 if (*c == '"') { |
| 326 // Port is mandatory. |
| 327 return false; |
| 328 } |
| 329 if (*c == '\\') { |
| 330 ++c; |
| 331 if (c == end) { |
| 332 return false; |
| 333 } |
| 334 } |
| 335 host->push_back(*c); |
| 336 } |
| 337 } |
| 338 if (c == end || *c != ':') { |
| 339 return false; |
| 340 } |
| 322 DCHECK_EQ(':', *c); | 341 DCHECK_EQ(':', *c); |
| 323 ++c; | 342 ++c; |
| 324 return ParsePositiveInteger16(c, end, port); | 343 return ParsePositiveInteger16(c, end, port); |
| 325 } | 344 } |
| 326 | 345 |
| 327 // static | 346 // static |
| 328 bool SpdyAltSvcWireFormat::ParsePositiveInteger16( | 347 bool SpdyAltSvcWireFormat::ParsePositiveInteger16( |
| 329 StringPiece::const_iterator c, | 348 StringPiece::const_iterator c, |
| 330 StringPiece::const_iterator end, | 349 StringPiece::const_iterator end, |
| 331 uint16_t* value) { | 350 uint16_t* value) { |
| 332 return ParsePositiveIntegerImpl<uint16_t>(c, end, value); | 351 return ParsePositiveIntegerImpl<uint16_t>(c, end, value); |
| 333 } | 352 } |
| 334 | 353 |
| 335 // static | 354 // static |
| 336 bool SpdyAltSvcWireFormat::ParsePositiveInteger32( | 355 bool SpdyAltSvcWireFormat::ParsePositiveInteger32( |
| 337 StringPiece::const_iterator c, | 356 StringPiece::const_iterator c, |
| 338 StringPiece::const_iterator end, | 357 StringPiece::const_iterator end, |
| 339 uint32_t* value) { | 358 uint32_t* value) { |
| 340 return ParsePositiveIntegerImpl<uint32_t>(c, end, value); | 359 return ParsePositiveIntegerImpl<uint32_t>(c, end, value); |
| 341 } | 360 } |
| 342 | 361 |
| 343 } // namespace net | 362 } // namespace net |
| OLD | NEW |