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 DLOG(INFO) << "Sending response for stream " << id(); | 100 DVLOG(1) << "Sending response for stream " << id(); |
101 SendHeadersAndBody(response->headers(), response->body()); | 101 SendHeadersAndBody(response->headers(), response->body()); |
102 } | 102 } |
103 | 103 |
104 void QuicSpdyServerStream::SendErrorResponse() { | 104 void QuicSpdyServerStream::SendErrorResponse() { |
105 DLOG(INFO) << "Sending error response for stream " << id(); | 105 DVLOG(1) << "Sending error response for stream " << id(); |
106 BalsaHeaders headers; | 106 BalsaHeaders headers; |
107 headers.SetResponseFirstlineFromStringPieces( | 107 headers.SetResponseFirstlineFromStringPieces( |
108 "HTTP/1.1", "500", "Server Error"); | 108 "HTTP/1.1", "500", "Server Error"); |
109 headers.ReplaceOrAppendHeader("content-length", "3"); | 109 headers.ReplaceOrAppendHeader("content-length", "3"); |
110 SendHeadersAndBody(headers, "bad"); | 110 SendHeadersAndBody(headers, "bad"); |
111 } | 111 } |
112 | 112 |
113 void QuicSpdyServerStream:: SendHeadersAndBody( | 113 void QuicSpdyServerStream:: SendHeadersAndBody( |
114 const BalsaHeaders& response_headers, | 114 const BalsaHeaders& response_headers, |
115 StringPiece body) { | 115 StringPiece body) { |
(...skipping 13 matching lines...) Expand all Loading... |
129 WriteOrBufferData(headers_string, body.empty()); | 129 WriteOrBufferData(headers_string, body.empty()); |
130 } | 130 } |
131 | 131 |
132 if (!body.empty()) { | 132 if (!body.empty()) { |
133 WriteOrBufferData(body, true); | 133 WriteOrBufferData(body, true); |
134 } | 134 } |
135 } | 135 } |
136 | 136 |
137 } // namespace tools | 137 } // namespace tools |
138 } // namespace net | 138 } // namespace net |
OLD | NEW |