OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "net/socket/next_proto.h" | |
6 | |
7 namespace net { | |
8 | |
9 NextProto NextProtoFromString(base::StringPiece proto_string) { | |
10 if (proto_string == "http1.1" || proto_string == "http/1.1") | |
11 return kProtoHTTP11; | |
12 // "npn-h2" and "npn-spdy/3.1" are accepted here so that persisted | |
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; | |
18 } | |
19 if (proto_string == "quic") | |
20 return kProtoQUIC; | |
21 | |
22 return kProtoUnknown; | |
23 } | |
24 | |
25 const char* NextProtoToString(NextProto next_proto) { | |
26 switch (next_proto) { | |
27 case kProtoHTTP11: | |
28 return "http/1.1"; | |
29 case kProtoHTTP2: | |
30 return "h2"; | |
31 case kProtoQUIC: | |
32 return "quic"; | |
33 case kProtoUnknown: | |
34 break; | |
35 } | |
36 return "unknown"; | |
37 } | |
38 | |
39 } // namespace net | |
OLD | NEW |