OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // This file contains data structures and utility functions used for serializing |
| 6 // and parsing alternative service header values, common to HTTP/1.1 header |
| 7 // fields and HTTP/2 and QUIC ALTSVC frames. See specification at |
| 8 // https://tools.ietf.org/id/draft-ietf-httpbis-alt-svc-06.html |
| 9 |
| 10 #ifndef NET_SPDY_SPDY_ALT_SVC_WIRE_FORMAT_H_ |
| 11 #define NET_SPDY_SPDY_ALT_SVC_WIRE_FORMAT_H_ |
| 12 |
| 13 #include "base/basictypes.h" |
| 14 #include "base/strings/string_piece.h" |
| 15 #include "net/base/net_export.h" |
| 16 |
| 17 using base::StringPiece; |
| 18 |
| 19 namespace net { |
| 20 |
| 21 namespace test { |
| 22 class SpdyAltSvcWireFormatPeer; |
| 23 } // namespace test |
| 24 |
| 25 class NET_EXPORT_PRIVATE SpdyAltSvcWireFormat { |
| 26 public: |
| 27 friend class test::SpdyAltSvcWireFormatPeer; |
| 28 static bool ParseHeaderFieldValue(StringPiece value, |
| 29 std::string* protocol_id, |
| 30 std::string* host, |
| 31 uint16* port, |
| 32 uint32* max_age, |
| 33 double* p); |
| 34 static std::string SerializeHeaderFieldValue(const std::string& protocol_id, |
| 35 const std::string& host, |
| 36 uint16 port, |
| 37 uint32 max_age, |
| 38 double p); |
| 39 |
| 40 private: |
| 41 static void SkipWhiteSpace(StringPiece::const_iterator* c, |
| 42 StringPiece::const_iterator end); |
| 43 static bool PercentDecode(StringPiece::const_iterator c, |
| 44 StringPiece::const_iterator end, |
| 45 std::string* output); |
| 46 static bool ParseAltAuthority(StringPiece::const_iterator c, |
| 47 StringPiece::const_iterator end, |
| 48 std::string* host, |
| 49 uint16* port); |
| 50 static bool ParsePositiveInteger16(StringPiece::const_iterator c, |
| 51 StringPiece::const_iterator end, |
| 52 uint16* value); |
| 53 static bool ParsePositiveInteger32(StringPiece::const_iterator c, |
| 54 StringPiece::const_iterator end, |
| 55 uint32* value); |
| 56 static bool ParseProbability(StringPiece::const_iterator c, |
| 57 StringPiece::const_iterator end, |
| 58 double* p); |
| 59 }; |
| 60 |
| 61 } // namespace net |
| 62 |
| 63 #endif // NET_SPDY_SPDY_ALT_SVC_WIRE_FORMAT_H_ |
OLD | NEW |