| 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 const AlternativeService& alternative_service, |
| 85 base::Time expiration) |
| 86 : alternative_service_(alternative_service), expiration_(expiration) {} |
| 87 |
| 88 AlternativeServiceInfo::AlternativeServiceInfo(NextProto protocol, |
| 89 const std::string& host, |
| 90 uint16_t port, |
| 91 base::Time expiration) |
| 92 : alternative_service_(protocol, host, port), expiration_(expiration) {} |
| 93 |
| 94 AlternativeServiceInfo::AlternativeServiceInfo( |
| 95 const AlternativeServiceInfo& alternative_service_info) = default; |
| 96 |
| 97 AlternativeServiceInfo& AlternativeServiceInfo::operator=( |
| 98 const AlternativeServiceInfo& alternative_service_info) = default; |
| 99 |
| 81 std::string AlternativeService::ToString() const { | 100 std::string AlternativeService::ToString() const { |
| 82 return base::StringPrintf("%s %s:%d", NextProtoToString(protocol), | 101 return base::StringPrintf("%s %s:%d", NextProtoToString(protocol), |
| 83 host.c_str(), port); | 102 host.c_str(), port); |
| 84 } | 103 } |
| 85 | 104 |
| 86 std::string AlternativeServiceInfo::ToString() const { | 105 std::string AlternativeServiceInfo::ToString() const { |
| 87 base::Time::Exploded exploded; | 106 base::Time::Exploded exploded; |
| 88 expiration.LocalExplode(&exploded); | 107 expiration_.LocalExplode(&exploded); |
| 89 return base::StringPrintf( | 108 return base::StringPrintf( |
| 90 "%s, expires %04d-%02d-%02d %02d:%02d:%02d", | 109 "%s, expires %04d-%02d-%02d %02d:%02d:%02d", |
| 91 alternative_service.ToString().c_str(), exploded.year, exploded.month, | 110 alternative_service_.ToString().c_str(), exploded.year, exploded.month, |
| 92 exploded.day_of_month, exploded.hour, exploded.minute, exploded.second); | 111 exploded.day_of_month, exploded.hour, exploded.minute, exploded.second); |
| 93 } | 112 } |
| 94 | 113 |
| 95 std::ostream& operator<<(std::ostream& os, | 114 std::ostream& operator<<(std::ostream& os, |
| 96 const AlternativeService& alternative_service) { | 115 const AlternativeService& alternative_service) { |
| 97 os << alternative_service.ToString(); | 116 os << alternative_service.ToString(); |
| 98 return os; | 117 return os; |
| 99 } | 118 } |
| 100 | 119 |
| 101 // static | 120 // static |
| 102 void HttpServerProperties::ForceHTTP11(SSLConfig* ssl_config) { | 121 void HttpServerProperties::ForceHTTP11(SSLConfig* ssl_config) { |
| 103 ssl_config->alpn_protos.clear(); | 122 ssl_config->alpn_protos.clear(); |
| 104 ssl_config->alpn_protos.push_back(kProtoHTTP11); | 123 ssl_config->alpn_protos.push_back(kProtoHTTP11); |
| 105 } | 124 } |
| 106 | 125 |
| 107 } // namespace net | 126 } // namespace net |
| OLD | NEW |