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

Side by Side Diff: net/server/http_server.cc

Issue 1340523002: Fix WebSocketServer extension parser. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ws-constructor-fix
Patch Set: Created 5 years, 2 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 | « net/net.gypi ('k') | net/server/web_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) 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/server/http_server.h" 5 #include "net/server/http_server.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 size_t pos = 0; 229 size_t pos = 0;
230 if (!ParseHeaders(read_buf->StartOfBuffer(), read_buf->GetSize(), 230 if (!ParseHeaders(read_buf->StartOfBuffer(), read_buf->GetSize(),
231 &request, &pos)) { 231 &request, &pos)) {
232 break; 232 break;
233 } 233 }
234 234
235 // Sets peer address if exists. 235 // Sets peer address if exists.
236 connection->socket()->GetPeerAddress(&request.peer); 236 connection->socket()->GetPeerAddress(&request.peer);
237 237
238 if (request.HasHeaderValue("connection", "upgrade")) { 238 if (request.HasHeaderValue("connection", "upgrade")) {
239 scoped_ptr<WebSocket> websocket = 239 connection->SetWebSocket(
240 WebSocket::CreateWebSocket(this, connection, request); 240 make_scoped_ptr(new WebSocket(this, connection)));
241 if (!websocket) // Not enough data was received.
242 break;
243 connection->SetWebSocket(websocket.Pass());
244 read_buf->DidConsume(pos); 241 read_buf->DidConsume(pos);
245 delegate_->OnWebSocketRequest(connection->id(), request); 242 delegate_->OnWebSocketRequest(connection->id(), request);
246 if (HasClosedConnection(connection)) 243 if (HasClosedConnection(connection))
247 return ERR_CONNECTION_CLOSED; 244 return ERR_CONNECTION_CLOSED;
248 continue; 245 continue;
249 } 246 }
250 247
251 const char kContentLength[] = "content-length"; 248 const char kContentLength[] = "content-length";
252 if (request.headers.count(kContentLength) > 0) { 249 if (request.headers.count(kContentLength) > 0) {
253 size_t content_length = 0; 250 size_t content_length = 0;
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 460
464 // This is called after any delegate callbacks are called to check if Close() 461 // This is called after any delegate callbacks are called to check if Close()
465 // has been called during callback processing. Using the pointer of connection, 462 // has been called during callback processing. Using the pointer of connection,
466 // |connection| is safe here because Close() deletes the connection in next run 463 // |connection| is safe here because Close() deletes the connection in next run
467 // loop. 464 // loop.
468 bool HttpServer::HasClosedConnection(HttpConnection* connection) { 465 bool HttpServer::HasClosedConnection(HttpConnection* connection) {
469 return FindConnection(connection->id()) != connection; 466 return FindConnection(connection->id()) != connection;
470 } 467 }
471 468
472 } // namespace net 469 } // namespace net
OLDNEW
« no previous file with comments | « net/net.gypi ('k') | net/server/web_socket.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698