OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/socket/next_proto.h" | 5 #include "net/socket/next_proto.h" |
6 | 6 |
7 namespace net { | 7 namespace net { |
8 | 8 |
9 NextProto NextProtoFromString(base::StringPiece proto_string) { | 9 NextProto NextProtoFromString(base::StringPiece proto_string) { |
10 if (proto_string == "http1.1" || proto_string == "http/1.1") | 10 if (proto_string == "http1.1" || proto_string == "http/1.1") |
11 return kProtoHTTP11; | 11 return kProtoHTTP11; |
12 // "npn-h2" and "npn-spdy/3.1" are accepted here so that persisted | 12 if (proto_string == "h2") { |
13 // settings with the old string can be loaded from disk. | |
14 // TODO(bnc): Remove around 2016 December. | |
15 if (proto_string == "h2" || proto_string == "npn-h2" || | |
16 proto_string == "npn-spdy/3.1") { | |
17 return kProtoHTTP2; | 13 return kProtoHTTP2; |
18 } | 14 } |
19 if (proto_string == "quic") | 15 if (proto_string == "quic") |
20 return kProtoQUIC; | 16 return kProtoQUIC; |
21 | 17 |
22 return kProtoUnknown; | 18 return kProtoUnknown; |
23 } | 19 } |
24 | 20 |
25 const char* NextProtoToString(NextProto next_proto) { | 21 const char* NextProtoToString(NextProto next_proto) { |
26 switch (next_proto) { | 22 switch (next_proto) { |
27 case kProtoHTTP11: | 23 case kProtoHTTP11: |
28 return "http/1.1"; | 24 return "http/1.1"; |
29 case kProtoHTTP2: | 25 case kProtoHTTP2: |
30 return "h2"; | 26 return "h2"; |
31 case kProtoQUIC: | 27 case kProtoQUIC: |
32 return "quic"; | 28 return "quic"; |
33 case kProtoUnknown: | 29 case kProtoUnknown: |
34 break; | 30 break; |
35 } | 31 } |
36 return "unknown"; | 32 return "unknown"; |
37 } | 33 } |
38 | 34 |
39 } // namespace net | 35 } // namespace net |
OLD | NEW |