Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(671)

Side by Side Diff: net/tools/quic/quic_spdy_server_stream.cc

Issue 177293008: Implement special behaviors (closing and timing out) in the test server. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/tools/quic/quic_in_memory_cache.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « net/tools/quic/quic_in_memory_cache.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698