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/tools/quic/quic_simple_server_session.h" | 5 #include "net/tools/quic/quic_simple_server_session.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 // Remove "host" field as push request is a directly generated HTTP2 request | 171 // Remove "host" field as push request is a directly generated HTTP2 request |
172 // which should use ":authority" instead of "host". | 172 // which should use ":authority" instead of "host". |
173 spdy_headers.erase("host"); | 173 spdy_headers.erase("host"); |
174 return spdy_headers; | 174 return spdy_headers; |
175 } | 175 } |
176 | 176 |
177 void QuicSimpleServerSession::SendPushPromise(QuicStreamId original_stream_id, | 177 void QuicSimpleServerSession::SendPushPromise(QuicStreamId original_stream_id, |
178 QuicStreamId promised_stream_id, | 178 QuicStreamId promised_stream_id, |
179 SpdyHeaderBlock headers) { | 179 SpdyHeaderBlock headers) { |
180 DVLOG(1) << "stream " << original_stream_id | 180 DVLOG(1) << "stream " << original_stream_id |
181 << " send PUSH_PROMISE for promised stream " << promised_stream_id; | 181 << " send PUSH_PROMISE for promised stream " << promised_stream_id; |
182 headers_stream()->WritePushPromise(original_stream_id, promised_stream_id, | 182 WritePushPromise(original_stream_id, promised_stream_id, std::move(headers)); |
183 std::move(headers)); | |
184 } | 183 } |
185 | 184 |
186 void QuicSimpleServerSession::HandlePromisedPushRequests() { | 185 void QuicSimpleServerSession::HandlePromisedPushRequests() { |
187 while (!promised_streams_.empty() && ShouldCreateOutgoingDynamicStream()) { | 186 while (!promised_streams_.empty() && ShouldCreateOutgoingDynamicStream()) { |
188 PromisedStreamInfo& promised_info = promised_streams_.front(); | 187 PromisedStreamInfo& promised_info = promised_streams_.front(); |
189 DCHECK_EQ(next_outgoing_stream_id(), promised_info.stream_id); | 188 DCHECK_EQ(next_outgoing_stream_id(), promised_info.stream_id); |
190 | 189 |
191 if (promised_info.is_cancelled) { | 190 if (promised_info.is_cancelled) { |
192 // This stream has been reset by client. Skip this stream id. | 191 // This stream has been reset by client. Skip this stream id. |
193 promised_streams_.pop_front(); | 192 promised_streams_.pop_front(); |
194 GetNextOutgoingStreamId(); | 193 GetNextOutgoingStreamId(); |
195 return; | 194 return; |
196 } | 195 } |
197 | 196 |
198 QuicSimpleServerStream* promised_stream = | 197 QuicSimpleServerStream* promised_stream = |
199 static_cast<QuicSimpleServerStream*>( | 198 static_cast<QuicSimpleServerStream*>( |
200 CreateOutgoingDynamicStream(promised_info.priority)); | 199 CreateOutgoingDynamicStream(promised_info.priority)); |
201 DCHECK(promised_stream != nullptr); | 200 DCHECK(promised_stream != nullptr); |
202 DCHECK_EQ(promised_info.stream_id, promised_stream->id()); | 201 DCHECK_EQ(promised_info.stream_id, promised_stream->id()); |
203 DVLOG(1) << "created server push stream " << promised_stream->id(); | 202 DVLOG(1) << "created server push stream " << promised_stream->id(); |
204 | 203 |
205 SpdyHeaderBlock request_headers(std::move(promised_info.request_headers)); | 204 SpdyHeaderBlock request_headers(std::move(promised_info.request_headers)); |
206 | 205 |
207 promised_streams_.pop_front(); | 206 promised_streams_.pop_front(); |
208 promised_stream->PushResponse(std::move(request_headers)); | 207 promised_stream->PushResponse(std::move(request_headers)); |
209 } | 208 } |
210 } | 209 } |
211 | 210 |
212 } // namespace net | 211 } // namespace net |
OLD | NEW |