| 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_reliable_server_stream.h" | 5 #include "net/tools/quic/quic_reliable_server_stream.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/singleton.h" | 8 #include "base/memory/singleton.h" |
| 9 #include "net/tools/quic/quic_in_memory_cache.h" | 9 #include "net/tools/quic/quic_in_memory_cache.h" |
| 10 | 10 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 void QuicReliableServerStream::SendResponse() { | 22 void QuicReliableServerStream::SendResponse() { |
| 23 // Find response in cache. If not found, send error response. | 23 // Find response in cache. If not found, send error response. |
| 24 const QuicInMemoryCache::Response* response = | 24 const QuicInMemoryCache::Response* response = |
| 25 QuicInMemoryCache::GetInstance()->GetResponse(headers_); | 25 QuicInMemoryCache::GetInstance()->GetResponse(headers_); |
| 26 if (response == NULL) { | 26 if (response == NULL) { |
| 27 SendErrorResponse(); | 27 SendErrorResponse(); |
| 28 return; | 28 return; |
| 29 } | 29 } |
| 30 | 30 |
| 31 DLOG(INFO) << "Sending response for stream " << id(); | 31 DVLOG(0) << "Sending response for stream " << id(); |
| 32 SendHeaders(response->headers()); | 32 SendHeaders(response->headers()); |
| 33 WriteData(response->body(), true); | 33 WriteData(response->body(), true); |
| 34 } | 34 } |
| 35 | 35 |
| 36 void QuicReliableServerStream::SendErrorResponse() { | 36 void QuicReliableServerStream::SendErrorResponse() { |
| 37 DLOG(INFO) << "Sending error response for stream " << id(); | 37 DVLOG(0) << "Sending error response for stream " << id(); |
| 38 BalsaHeaders headers; | 38 BalsaHeaders headers; |
| 39 headers.SetResponseFirstlineFromStringPieces( | 39 headers.SetResponseFirstlineFromStringPieces( |
| 40 "HTTP/1.1", "500", "Server Error"); | 40 "HTTP/1.1", "500", "Server Error"); |
| 41 headers.ReplaceOrAppendHeader("content-length", "3"); | 41 headers.ReplaceOrAppendHeader("content-length", "3"); |
| 42 SendHeaders(headers); | 42 SendHeaders(headers); |
| 43 WriteData("bad", true); | 43 WriteData("bad", true); |
| 44 } | 44 } |
| 45 | 45 |
| 46 QuicConsumedData QuicReliableServerStream::WriteData(StringPiece data, | 46 QuicConsumedData QuicReliableServerStream::WriteData(StringPiece data, |
| 47 bool fin) { | 47 bool fin) { |
| 48 // We only support SPDY and HTTP, and neither handles bidirectional streaming. | 48 // We only support SPDY and HTTP, and neither handles bidirectional streaming. |
| 49 if (!read_side_closed()) { | 49 if (!read_side_closed()) { |
| 50 CloseReadSide(); | 50 CloseReadSide(); |
| 51 } | 51 } |
| 52 return ReliableQuicStream::WriteData(data, fin); | 52 return ReliableQuicStream::WriteData(data, fin); |
| 53 } | 53 } |
| 54 | 54 |
| 55 } // namespace tools | 55 } // namespace tools |
| 56 } // namespace net | 56 } // namespace net |
| OLD | NEW |