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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 size_t pos = 0; | 232 size_t pos = 0; |
233 if (!ParseHeaders(read_buf->StartOfBuffer(), read_buf->GetSize(), | 233 if (!ParseHeaders(read_buf->StartOfBuffer(), read_buf->GetSize(), |
234 &request, &pos)) { | 234 &request, &pos)) { |
235 break; | 235 break; |
236 } | 236 } |
237 | 237 |
238 // Sets peer address if exists. | 238 // Sets peer address if exists. |
239 connection->socket()->GetPeerAddress(&request.peer); | 239 connection->socket()->GetPeerAddress(&request.peer); |
240 | 240 |
241 if (request.HasHeaderValue("connection", "upgrade")) { | 241 if (request.HasHeaderValue("connection", "upgrade")) { |
242 connection->SetWebSocket( | 242 connection->SetWebSocket(base::MakeUnique<WebSocket>(this, connection)); |
243 base::WrapUnique(new WebSocket(this, connection))); | |
244 read_buf->DidConsume(pos); | 243 read_buf->DidConsume(pos); |
245 delegate_->OnWebSocketRequest(connection->id(), request); | 244 delegate_->OnWebSocketRequest(connection->id(), request); |
246 if (HasClosedConnection(connection)) | 245 if (HasClosedConnection(connection)) |
247 return ERR_CONNECTION_CLOSED; | 246 return ERR_CONNECTION_CLOSED; |
248 continue; | 247 continue; |
249 } | 248 } |
250 | 249 |
251 const char kContentLength[] = "content-length"; | 250 const char kContentLength[] = "content-length"; |
252 if (request.headers.count(kContentLength) > 0) { | 251 if (request.headers.count(kContentLength) > 0) { |
253 size_t content_length = 0; | 252 size_t content_length = 0; |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 | 461 |
463 // This is called after any delegate callbacks are called to check if Close() | 462 // This is called after any delegate callbacks are called to check if Close() |
464 // has been called during callback processing. Using the pointer of connection, | 463 // has been called during callback processing. Using the pointer of connection, |
465 // |connection| is safe here because Close() deletes the connection in next run | 464 // |connection| is safe here because Close() deletes the connection in next run |
466 // loop. | 465 // loop. |
467 bool HttpServer::HasClosedConnection(HttpConnection* connection) { | 466 bool HttpServer::HasClosedConnection(HttpConnection* connection) { |
468 return FindConnection(connection->id()) != connection; | 467 return FindConnection(connection->id()) != connection; |
469 } | 468 } |
470 | 469 |
471 } // namespace net | 470 } // namespace net |
OLD | NEW |