| 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 // This file contains data structures and utility functions used for serializing | 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 | 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 | 7 // fields and HTTP/2 and QUIC ALTSVC frames. See specification at |
| 8 // https://httpwg.github.io/http-extensions/alt-svc.html. | 8 // https://httpwg.github.io/http-extensions/alt-svc.html. |
| 9 | 9 |
| 10 #ifndef NET_SPDY_SPDY_ALT_SVC_WIRE_FORMAT_H_ | 10 #ifndef NET_SPDY_SPDY_ALT_SVC_WIRE_FORMAT_H_ |
| 11 #define NET_SPDY_SPDY_ALT_SVC_WIRE_FORMAT_H_ | 11 #define NET_SPDY_SPDY_ALT_SVC_WIRE_FORMAT_H_ |
| 12 | 12 |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "base/basictypes.h" | 15 #include "base/basictypes.h" |
| 16 #include "base/strings/string_piece.h" | 16 #include "base/strings/string_piece.h" |
| 17 #include "net/base/net_export.h" | 17 #include "net/base/net_export.h" |
| 18 | 18 |
| 19 using base::StringPiece; | |
| 20 | |
| 21 namespace net { | 19 namespace net { |
| 22 | 20 |
| 23 namespace test { | 21 namespace test { |
| 24 class SpdyAltSvcWireFormatPeer; | 22 class SpdyAltSvcWireFormatPeer; |
| 25 } // namespace test | 23 } // namespace test |
| 26 | 24 |
| 27 class NET_EXPORT_PRIVATE SpdyAltSvcWireFormat { | 25 class NET_EXPORT_PRIVATE SpdyAltSvcWireFormat { |
| 28 public: | 26 public: |
| 29 using VersionVector = std::vector<uint16>; | 27 using VersionVector = std::vector<uint16>; |
| 30 | 28 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 55 port == other.port && version == other.version && | 53 port == other.port && version == other.version && |
| 56 max_age == other.max_age && probability == other.probability; | 54 max_age == other.max_age && probability == other.probability; |
| 57 } | 55 } |
| 58 }; | 56 }; |
| 59 // An empty vector means alternative services should be cleared for given | 57 // An empty vector means alternative services should be cleared for given |
| 60 // origin. Note that the wire format for this is the string "clear", not an | 58 // origin. Note that the wire format for this is the string "clear", not an |
| 61 // empty value (which is invalid). | 59 // empty value (which is invalid). |
| 62 typedef std::vector<AlternativeService> AlternativeServiceVector; | 60 typedef std::vector<AlternativeService> AlternativeServiceVector; |
| 63 | 61 |
| 64 friend class test::SpdyAltSvcWireFormatPeer; | 62 friend class test::SpdyAltSvcWireFormatPeer; |
| 65 static bool ParseHeaderFieldValue(StringPiece value, | 63 static bool ParseHeaderFieldValue(base::StringPiece value, |
| 66 AlternativeServiceVector* altsvc_vector); | 64 AlternativeServiceVector* altsvc_vector); |
| 67 static std::string SerializeHeaderFieldValue( | 65 static std::string SerializeHeaderFieldValue( |
| 68 const AlternativeServiceVector& altsvc_vector); | 66 const AlternativeServiceVector& altsvc_vector); |
| 69 | 67 |
| 70 private: | 68 private: |
| 71 static void SkipWhiteSpace(StringPiece::const_iterator* c, | 69 static void SkipWhiteSpace(base::StringPiece::const_iterator* c, |
| 72 StringPiece::const_iterator end); | 70 base::StringPiece::const_iterator end); |
| 73 static bool PercentDecode(StringPiece::const_iterator c, | 71 static bool PercentDecode(base::StringPiece::const_iterator c, |
| 74 StringPiece::const_iterator end, | 72 base::StringPiece::const_iterator end, |
| 75 std::string* output); | 73 std::string* output); |
| 76 static bool ParseAltAuthority(StringPiece::const_iterator c, | 74 static bool ParseAltAuthority(base::StringPiece::const_iterator c, |
| 77 StringPiece::const_iterator end, | 75 base::StringPiece::const_iterator end, |
| 78 std::string* host, | 76 std::string* host, |
| 79 uint16* port); | 77 uint16* port); |
| 80 static bool ParsePositiveInteger16(StringPiece::const_iterator c, | 78 static bool ParsePositiveInteger16(base::StringPiece::const_iterator c, |
| 81 StringPiece::const_iterator end, | 79 base::StringPiece::const_iterator end, |
| 82 uint16* value); | 80 uint16* value); |
| 83 static bool ParsePositiveInteger32(StringPiece::const_iterator c, | 81 static bool ParsePositiveInteger32(base::StringPiece::const_iterator c, |
| 84 StringPiece::const_iterator end, | 82 base::StringPiece::const_iterator end, |
| 85 uint32* value); | 83 uint32* value); |
| 86 static bool ParseProbability(StringPiece::const_iterator c, | 84 static bool ParseProbability(base::StringPiece::const_iterator c, |
| 87 StringPiece::const_iterator end, | 85 base::StringPiece::const_iterator end, |
| 88 double* probability); | 86 double* probability); |
| 89 }; | 87 }; |
| 90 | 88 |
| 91 } // namespace net | 89 } // namespace net |
| 92 | 90 |
| 93 #endif // NET_SPDY_SPDY_ALT_SVC_WIRE_FORMAT_H_ | 91 #endif // NET_SPDY_SPDY_ALT_SVC_WIRE_FORMAT_H_ |
| OLD | NEW |