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

Side by Side Diff: chrome_frame/test/test_server.cc

Issue 2868036: Brushed up listen socket: (Closed)
Patch Set: Lint. Created 10 years, 5 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
« no previous file with comments | « chrome_frame/test/test_server.h ('k') | net/base/listen_socket.h » ('j') | 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "base/logging.h" 5 #include "base/logging.h"
6 #include "base/registry.h" 6 #include "base/registry.h"
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 8
9 #include "chrome_frame/test/test_server.h" 9 #include "chrome_frame/test/test_server.h"
10 10
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 } 165 }
166 return NULL; 166 return NULL;
167 } 167 }
168 168
169 void SimpleWebServer::DidAccept(ListenSocket* server, 169 void SimpleWebServer::DidAccept(ListenSocket* server,
170 ListenSocket* connection) { 170 ListenSocket* connection) {
171 connections_.push_back(new Connection(connection)); 171 connections_.push_back(new Connection(connection));
172 } 172 }
173 173
174 void SimpleWebServer::DidRead(ListenSocket* connection, 174 void SimpleWebServer::DidRead(ListenSocket* connection,
175 const std::string& data) { 175 const char* data,
176 int len) {
176 Connection* c = FindConnection(connection); 177 Connection* c = FindConnection(connection);
177 DCHECK(c); 178 DCHECK(c);
178 Request& r = c->request(); 179 Request& r = c->request();
179 r.OnDataReceived(data); 180 std::string str(data, len);
181 r.OnDataReceived(str);
180 if (r.AllContentReceived()) { 182 if (r.AllContentReceived()) {
181 const Request& request = c->request(); 183 const Request& request = c->request();
182 Response* response = FindResponse(request); 184 Response* response = FindResponse(request);
183 if (response) { 185 if (response) {
184 std::string headers; 186 std::string headers;
185 if (!response->GetCustomHeaders(&headers)) { 187 if (!response->GetCustomHeaders(&headers)) {
186 std::string content_type; 188 std::string content_type;
187 if (!response->GetContentType(&content_type)) 189 if (!response->GetContentType(&content_type))
188 content_type = kDefaultContentType; 190 content_type = kDefaultContentType;
189 headers = StringPrintf(kDefaultHeaderTemplate, kStatusOk, 191 headers = StringPrintf(kDefaultHeaderTemplate, kStatusOk,
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 ConnectionList::iterator it = FindConnection(socket); 242 ConnectionList::iterator it = FindConnection(socket);
241 if (it != connection_list_.end()) 243 if (it != connection_list_.end())
242 return *it; 244 return *it;
243 return NULL; 245 return NULL;
244 } 246 }
245 247
246 void HTTPTestServer::DidAccept(ListenSocket* server, ListenSocket* socket) { 248 void HTTPTestServer::DidAccept(ListenSocket* server, ListenSocket* socket) {
247 connection_list_.push_back(new ConfigurableConnection(socket)); 249 connection_list_.push_back(new ConfigurableConnection(socket));
248 } 250 }
249 251
250 void HTTPTestServer::DidRead(ListenSocket* socket, const std::string& data) { 252 void HTTPTestServer::DidRead(ListenSocket* socket,
253 const char* data,
254 int len) {
251 scoped_refptr<ConfigurableConnection> connection = 255 scoped_refptr<ConfigurableConnection> connection =
252 ConnectionFromSocket(socket); 256 ConnectionFromSocket(socket);
253 if (connection) { 257 if (connection) {
254 connection->r_.OnDataReceived(data); 258 std::string str(data, len);
259 connection->r_.OnDataReceived(str);
255 if (connection->r_.AllContentReceived()) { 260 if (connection->r_.AllContentReceived()) {
256 if (LowerCaseEqualsASCII(connection->r_.method(), "post")) 261 if (LowerCaseEqualsASCII(connection->r_.method(), "post"))
257 this->Post(connection, connection->r_.path(), connection->r_); 262 this->Post(connection, connection->r_.path(), connection->r_);
258 else 263 else
259 this->Get(connection, connection->r_.path(), connection->r_); 264 this->Get(connection, connection->r_.path(), connection->r_);
260 } 265 }
261 } 266 }
262 } 267 }
263 268
264 void HTTPTestServer::DidClose(ListenSocket* socket) { 269 void HTTPTestServer::DidClose(ListenSocket* socket) {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 data_ = headers; 328 data_ = headers;
324 data_.append(content_length_header); 329 data_.append(content_length_header);
325 data_.append("\r\n"); 330 data_.append("\r\n");
326 } 331 }
327 332
328 MessageLoop::current()->PostDelayedTask(FROM_HERE, 333 MessageLoop::current()->PostDelayedTask(FROM_HERE,
329 NewRunnableMethod(this, &ConfigurableConnection::SendChunk), 334 NewRunnableMethod(this, &ConfigurableConnection::SendChunk),
330 options.timeout_); 335 options.timeout_);
331 } 336 }
332 } // namespace test_server 337 } // namespace test_server
OLDNEW
« no previous file with comments | « chrome_frame/test/test_server.h ('k') | net/base/listen_socket.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698