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/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 Loading... |
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 scoped_ptr<WebSocket> websocket = |
240 WebSocket::CreateWebSocket(this, connection, request)); | 240 WebSocket::CreateWebSocket(this, connection, request); |
241 if (!websocket) // Not enough data was received. | 241 if (!websocket) // Not enough data was received. |
242 break; | 242 break; |
243 connection->SetWebSocket(websocket.Pass()); | 243 connection->SetWebSocket(websocket.Pass()); |
244 read_buf->DidConsume(pos); | 244 read_buf->DidConsume(pos); |
245 delegate_->OnWebSocketRequest(connection->id(), request); | 245 delegate_->OnWebSocketRequest(connection->id(), request); |
246 if (HasClosedConnection(connection)) | 246 if (HasClosedConnection(connection)) |
247 return ERR_CONNECTION_CLOSED; | 247 return ERR_CONNECTION_CLOSED; |
248 continue; | 248 continue; |
249 } | 249 } |
250 | 250 |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 | 463 |
464 // This is called after any delegate callbacks are called to check if Close() | 464 // 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, | 465 // has been called during callback processing. Using the pointer of connection, |
466 // |connection| is safe here because Close() deletes the connection in next run | 466 // |connection| is safe here because Close() deletes the connection in next run |
467 // loop. | 467 // loop. |
468 bool HttpServer::HasClosedConnection(HttpConnection* connection) { | 468 bool HttpServer::HasClosedConnection(HttpConnection* connection) { |
469 return FindConnection(connection->id()) != connection; | 469 return FindConnection(connection->id()) != connection; |
470 } | 470 } |
471 | 471 |
472 } // namespace net | 472 } // namespace net |
OLD | NEW |