OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/http/http_server_properties.h" | 5 #include "net/http/http_server_properties.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/metrics/histogram_macros.h" | 8 #include "base/metrics/histogram_macros.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "net/socket/ssl_client_socket.h" | 10 #include "net/socket/ssl_client_socket.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 return false; | 71 return false; |
72 case kProtoHTTP2: | 72 case kProtoHTTP2: |
73 return true; | 73 return true; |
74 case kProtoQUIC: | 74 case kProtoQUIC: |
75 return true; | 75 return true; |
76 } | 76 } |
77 NOTREACHED(); | 77 NOTREACHED(); |
78 return false; | 78 return false; |
79 } | 79 } |
80 | 80 |
| 81 AlternativeServiceInfo::AlternativeServiceInfo() : alternative_service() {} |
| 82 |
| 83 AlternativeServiceInfo::~AlternativeServiceInfo() {} |
| 84 |
| 85 AlternativeServiceInfo::AlternativeServiceInfo( |
| 86 const AlternativeService& alternative_service, |
| 87 base::Time expiration) |
| 88 : alternative_service(alternative_service), expiration(expiration) {} |
| 89 |
| 90 AlternativeServiceInfo::AlternativeServiceInfo( |
| 91 const AlternativeService& alternative_service, |
| 92 base::Time expiration, |
| 93 const QuicVersionVector& advertised_versions) |
| 94 : alternative_service(alternative_service), |
| 95 expiration(expiration), |
| 96 advertised_versions(advertised_versions) {} |
| 97 |
| 98 AlternativeServiceInfo::AlternativeServiceInfo( |
| 99 const AlternativeServiceInfo& alternative_service_info) = default; |
| 100 |
81 std::string AlternativeService::ToString() const { | 101 std::string AlternativeService::ToString() const { |
82 return base::StringPrintf("%s %s:%d", NextProtoToString(protocol), | 102 return base::StringPrintf("%s %s:%d", NextProtoToString(protocol), |
83 host.c_str(), port); | 103 host.c_str(), port); |
84 } | 104 } |
85 | 105 |
86 std::string AlternativeServiceInfo::ToString() const { | 106 std::string AlternativeServiceInfo::ToString() const { |
87 base::Time::Exploded exploded; | 107 base::Time::Exploded exploded; |
88 expiration.LocalExplode(&exploded); | 108 expiration.LocalExplode(&exploded); |
89 return base::StringPrintf( | 109 return base::StringPrintf( |
90 "%s, expires %04d-%02d-%02d %02d:%02d:%02d", | 110 "%s, expires %04d-%02d-%02d %02d:%02d:%02d", |
91 alternative_service.ToString().c_str(), exploded.year, exploded.month, | 111 alternative_service.ToString().c_str(), exploded.year, exploded.month, |
92 exploded.day_of_month, exploded.hour, exploded.minute, exploded.second); | 112 exploded.day_of_month, exploded.hour, exploded.minute, exploded.second); |
93 } | 113 } |
94 | 114 |
95 std::ostream& operator<<(std::ostream& os, | 115 std::ostream& operator<<(std::ostream& os, |
96 const AlternativeService& alternative_service) { | 116 const AlternativeService& alternative_service) { |
97 os << alternative_service.ToString(); | 117 os << alternative_service.ToString(); |
98 return os; | 118 return os; |
99 } | 119 } |
100 | 120 |
101 // static | 121 // static |
102 void HttpServerProperties::ForceHTTP11(SSLConfig* ssl_config) { | 122 void HttpServerProperties::ForceHTTP11(SSLConfig* ssl_config) { |
103 ssl_config->alpn_protos.clear(); | 123 ssl_config->alpn_protos.clear(); |
104 ssl_config->alpn_protos.push_back(kProtoHTTP11); | 124 ssl_config->alpn_protos.push_back(kProtoHTTP11); |
105 } | 125 } |
106 | 126 |
107 } // namespace net | 127 } // namespace net |
OLD | NEW |