forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
next_proto.cc
35 lines (29 loc) · 827 Bytes
/
next_proto.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "net/socket/next_proto.h"
namespace net {
NextProto NextProtoFromString(base::StringPiece proto_string) {
if (proto_string == "http1.1" || proto_string == "http/1.1")
return kProtoHTTP11;
if (proto_string == "h2") {
return kProtoHTTP2;
}
if (proto_string == "quic" || proto_string == "hq")
return kProtoQUIC;
return kProtoUnknown;
}
const char* NextProtoToString(NextProto next_proto) {
switch (next_proto) {
case kProtoHTTP11:
return "http/1.1";
case kProtoHTTP2:
return "h2";
case kProtoQUIC:
return "quic";
case kProtoUnknown:
break;
}
return "unknown";
}
} // namespace net