1 // Copyright 2016 The Chromium Authors 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/spdy/multiplexed_http_stream.h" 6 7 #include <utility> 8 9 #include "base/notreached.h" 10 #include "net/http/http_raw_request_headers.h" 11 #include "net/third_party/quiche/src/quiche/spdy/core/http2_header_block.h" 12 13 namespace net { 14 MultiplexedHttpStream(std::unique_ptr<MultiplexedSessionHandle> session)15MultiplexedHttpStream::MultiplexedHttpStream( 16 std::unique_ptr<MultiplexedSessionHandle> session) 17 : session_(std::move(session)) {} 18 19 MultiplexedHttpStream::~MultiplexedHttpStream() = default; 20 GetRemoteEndpoint(IPEndPoint * endpoint)21int MultiplexedHttpStream::GetRemoteEndpoint(IPEndPoint* endpoint) { 22 return session_->GetRemoteEndpoint(endpoint); 23 } 24 GetSSLInfo(SSLInfo * ssl_info)25void MultiplexedHttpStream::GetSSLInfo(SSLInfo* ssl_info) { 26 session_->GetSSLInfo(ssl_info); 27 } 28 SaveSSLInfo()29void MultiplexedHttpStream::SaveSSLInfo() { 30 session_->SaveSSLInfo(); 31 } 32 Drain(HttpNetworkSession * session)33void MultiplexedHttpStream::Drain(HttpNetworkSession* session) { 34 NOTREACHED(); 35 Close(false); 36 delete this; 37 } 38 RenewStreamForAuth()39std::unique_ptr<HttpStream> MultiplexedHttpStream::RenewStreamForAuth() { 40 return nullptr; 41 } 42 SetConnectionReused()43void MultiplexedHttpStream::SetConnectionReused() {} 44 CanReuseConnection() const45bool MultiplexedHttpStream::CanReuseConnection() const { 46 // Multiplexed streams aren't considered reusable. 47 return false; 48 } 49 SetRequestHeadersCallback(RequestHeadersCallback callback)50void MultiplexedHttpStream::SetRequestHeadersCallback( 51 RequestHeadersCallback callback) { 52 request_headers_callback_ = std::move(callback); 53 } 54 DispatchRequestHeadersCallback(const spdy::Http2HeaderBlock & spdy_headers)55void MultiplexedHttpStream::DispatchRequestHeadersCallback( 56 const spdy::Http2HeaderBlock& spdy_headers) { 57 if (!request_headers_callback_) 58 return; 59 HttpRawRequestHeaders raw_headers; 60 for (const auto& entry : spdy_headers) { 61 raw_headers.Add(entry.first, entry.second); 62 } 63 request_headers_callback_.Run(std::move(raw_headers)); 64 } 65 66 } // namespace net 67