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_stream.h" | 5 #include "net/tools/quic/quic_simple_server_stream.h" |
6 | 6 |
7 #include <list> | 7 #include <list> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 SpdyHeaderBlock response_headers, | 227 SpdyHeaderBlock response_headers, |
228 StringPiece body) { | 228 StringPiece body) { |
229 SendHeadersAndBodyAndTrailers(std::move(response_headers), body, | 229 SendHeadersAndBodyAndTrailers(std::move(response_headers), body, |
230 SpdyHeaderBlock()); | 230 SpdyHeaderBlock()); |
231 } | 231 } |
232 | 232 |
233 void QuicSimpleServerStream::SendHeadersAndBodyAndTrailers( | 233 void QuicSimpleServerStream::SendHeadersAndBodyAndTrailers( |
234 SpdyHeaderBlock response_headers, | 234 SpdyHeaderBlock response_headers, |
235 StringPiece body, | 235 StringPiece body, |
236 SpdyHeaderBlock response_trailers) { | 236 SpdyHeaderBlock response_trailers) { |
237 // This server only supports SPDY and HTTP, and neither handles bidirectional | 237 if (!allow_bidirectional_data() && !reading_stopped()) { |
238 // streaming. | |
239 if (!reading_stopped()) { | |
240 StopReading(); | 238 StopReading(); |
241 } | 239 } |
242 | 240 |
243 // Send the headers, with a FIN if there's nothing else to send. | 241 // Send the headers, with a FIN if there's nothing else to send. |
244 bool send_fin = (body.empty() && response_trailers.empty()); | 242 bool send_fin = (body.empty() && response_trailers.empty()); |
245 DVLOG(1) << "Writing headers (fin = " << send_fin | 243 DVLOG(1) << "Writing headers (fin = " << send_fin |
246 << ") : " << response_headers.DebugString(); | 244 << ") : " << response_headers.DebugString(); |
247 WriteHeaders(std::move(response_headers), send_fin, nullptr); | 245 WriteHeaders(std::move(response_headers), send_fin, nullptr); |
248 if (send_fin) { | 246 if (send_fin) { |
249 // Nothing else to send. | 247 // Nothing else to send. |
(...skipping 16 matching lines...) Expand all Loading... |
266 DVLOG(1) << "Writing trailers (fin = true): " | 264 DVLOG(1) << "Writing trailers (fin = true): " |
267 << response_trailers.DebugString(); | 265 << response_trailers.DebugString(); |
268 WriteTrailers(std::move(response_trailers), nullptr); | 266 WriteTrailers(std::move(response_trailers), nullptr); |
269 } | 267 } |
270 | 268 |
271 const char* const QuicSimpleServerStream::kErrorResponseBody = "bad"; | 269 const char* const QuicSimpleServerStream::kErrorResponseBody = "bad"; |
272 const char* const QuicSimpleServerStream::kNotFoundResponseBody = | 270 const char* const QuicSimpleServerStream::kNotFoundResponseBody = |
273 "file not found"; | 271 "file not found"; |
274 | 272 |
275 } // namespace net | 273 } // namespace net |
OLD | NEW |