Index: net/spdy/spdy_session.cc |
diff --git a/net/spdy/spdy_session.cc b/net/spdy/spdy_session.cc |
index a9565db39265566325f9b983c17c6cb9911cb69e..9fc4d6daae21bae76fcea3253e8156be21f0c1dc 100644 |
--- a/net/spdy/spdy_session.cc |
+++ b/net/spdy/spdy_session.cc |
@@ -2485,6 +2485,60 @@ void SpdySession::OnHeaders(SpdyStreamId stream_id, |
} |
} |
+void SpdySession::OnAltSvc( |
+ SpdyStreamId stream_id, |
+ base::StringPiece origin, |
+ const SpdyAltSvcWireFormat::AlternativeServiceVector& altsvc_vector) { |
+ if (!is_secure_) |
+ return; |
+ |
+ url::SchemeHostPort scheme_host_port; |
+ if (stream_id == 0) { |
+ if (origin.empty()) |
+ return; |
Ryan Hamilton
2016/06/03 19:05:18
I'm surprised that this is, in the spec, to be ign
Bence
2016/06/03 20:57:52
Acknowledged.
|
+ const GURL gurl(origin); |
+ if (!gurl.SchemeIs("https")) |
+ return; |
+ SSLInfo ssl_info; |
+ bool was_npn_negotiated; |
+ NextProto protocol_negotiated = kProtoUnknown; |
+ if (!GetSSLInfo(&ssl_info, &was_npn_negotiated, &protocol_negotiated)) |
+ return; |
+ if (!CanPool(transport_security_state_, ssl_info, host_port_pair().host(), |
+ gurl.host())) { |
+ return; |
+ } |
+ scheme_host_port = url::SchemeHostPort(gurl); |
+ } else { |
+ if (!origin.empty()) |
+ return; |
+ const ActiveStreamMap::iterator it = active_streams_.find(stream_id); |
+ if (it == active_streams_.end()) |
+ return; |
+ const GURL& gurl(it->second.stream->url()); |
+ if (!gurl.SchemeIs("https")) |
+ return; |
+ scheme_host_port = url::SchemeHostPort(gurl); |
+ } |
+ |
+ AlternativeServiceInfoVector alternative_service_info_vector; |
Ryan Hamilton
2016/06/03 19:05:18
I think there's a constructor you can call to set
Bence
2016/06/03 20:57:52
Didn't find a constructor call, how about std::vec
Ryan Hamilton
2016/06/03 21:26:18
Does this work?
http://en.cppreference.com/w/cpp/
Bence
2016/06/04 02:43:55
It could work, but note that the for loop can skip
|
+ const base::Time now(base::Time::Now()); |
+ for (const SpdyAltSvcWireFormat::AlternativeService& altsvc : altsvc_vector) { |
+ const AlternateProtocol protocol = |
+ AlternateProtocolFromString(altsvc.protocol_id); |
+ if (protocol == UNINITIALIZED_ALTERNATE_PROTOCOL) |
+ continue; |
+ const AlternativeService alternative_service(protocol, altsvc.host, |
+ altsvc.port); |
+ const base::Time expiration = |
+ now + base::TimeDelta::FromSeconds(altsvc.max_age); |
+ alternative_service_info_vector.push_back( |
+ AlternativeServiceInfo(alternative_service, expiration)); |
+ } |
+ http_server_properties_->SetAlternativeServices( |
+ scheme_host_port, alternative_service_info_vector); |
+} |
+ |
bool SpdySession::OnUnknownFrame(SpdyStreamId stream_id, int frame_type) { |
// Validate stream id. |
// Was the frame sent on a stream id that has not been used in this session? |