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_spdy_server_stream.h" | 5 #include "net/tools/quic/quic_spdy_server_stream.h" |
6 | 6 |
7 #include "base/memory/singleton.h" | 7 #include "base/memory/singleton.h" |
8 #include "net/quic/quic_session.h" | 8 #include "net/quic/quic_session.h" |
9 #include "net/spdy/spdy_framer.h" | 9 #include "net/spdy/spdy_framer.h" |
10 #include "net/tools/quic/quic_in_memory_cache.h" | 10 #include "net/tools/quic/quic_in_memory_cache.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 | 90 |
91 void QuicSpdyServerStream::SendResponse() { | 91 void QuicSpdyServerStream::SendResponse() { |
92 // Find response in cache. If not found, send error response. | 92 // Find response in cache. If not found, send error response. |
93 const QuicInMemoryCache::Response* response = | 93 const QuicInMemoryCache::Response* response = |
94 QuicInMemoryCache::GetInstance()->GetResponse(headers_); | 94 QuicInMemoryCache::GetInstance()->GetResponse(headers_); |
95 if (response == NULL) { | 95 if (response == NULL) { |
96 SendErrorResponse(); | 96 SendErrorResponse(); |
97 return; | 97 return; |
98 } | 98 } |
99 | 99 |
| 100 if (response->response_type() == QuicInMemoryCache::CLOSE_CONNECTION) { |
| 101 DVLOG(1) << "Special response: closing connection."; |
| 102 CloseConnection(QUIC_NO_ERROR); |
| 103 return; |
| 104 } |
| 105 |
| 106 if (response->response_type() == QuicInMemoryCache::IGNORE_REQUEST) { |
| 107 DVLOG(1) << "Special response: ignoring request."; |
| 108 return; |
| 109 } |
| 110 |
100 DVLOG(1) << "Sending response for stream " << id(); | 111 DVLOG(1) << "Sending response for stream " << id(); |
101 SendHeadersAndBody(response->headers(), response->body()); | 112 SendHeadersAndBody(response->headers(), response->body()); |
102 } | 113 } |
103 | 114 |
104 void QuicSpdyServerStream::SendErrorResponse() { | 115 void QuicSpdyServerStream::SendErrorResponse() { |
105 DVLOG(1) << "Sending error response for stream " << id(); | 116 DVLOG(1) << "Sending error response for stream " << id(); |
106 BalsaHeaders headers; | 117 BalsaHeaders headers; |
107 headers.SetResponseFirstlineFromStringPieces( | 118 headers.SetResponseFirstlineFromStringPieces( |
108 "HTTP/1.1", "500", "Server Error"); | 119 "HTTP/1.1", "500", "Server Error"); |
109 headers.ReplaceOrAppendHeader("content-length", "3"); | 120 headers.ReplaceOrAppendHeader("content-length", "3"); |
(...skipping 19 matching lines...) Expand all Loading... |
129 WriteOrBufferData(headers_string, body.empty()); | 140 WriteOrBufferData(headers_string, body.empty()); |
130 } | 141 } |
131 | 142 |
132 if (!body.empty()) { | 143 if (!body.empty()) { |
133 WriteOrBufferData(body, true); | 144 WriteOrBufferData(body, true); |
134 } | 145 } |
135 } | 146 } |
136 | 147 |
137 } // namespace tools | 148 } // namespace tools |
138 } // namespace net | 149 } // namespace net |
OLD | NEW |