| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/web_socket.h" | 5 #include "net/server/web_socket.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/rand_util.h" | 10 #include "base/rand_util.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 if (p_char[i] >= '0' && p_char[i] <= '9') | 30 if (p_char[i] >= '0' && p_char[i] <= '9') |
| 31 result.append(&p_char[i], 1); | 31 result.append(&p_char[i], 1); |
| 32 else if (p_char[i] == ' ') | 32 else if (p_char[i] == ' ') |
| 33 spaces++; | 33 spaces++; |
| 34 } | 34 } |
| 35 if (spaces == 0) | 35 if (spaces == 0) |
| 36 return 0; | 36 return 0; |
| 37 int64 number = 0; | 37 int64 number = 0; |
| 38 if (!base::StringToInt64(result, &number)) | 38 if (!base::StringToInt64(result, &number)) |
| 39 return 0; | 39 return 0; |
| 40 return htonl(static_cast<uint32>(number / spaces)); | 40 return base::HostToNet32(static_cast<uint32>(number / spaces)); |
| 41 } | 41 } |
| 42 | 42 |
| 43 class WebSocketHixie76 : public net::WebSocket { | 43 class WebSocketHixie76 : public net::WebSocket { |
| 44 public: | 44 public: |
| 45 static net::WebSocket* Create(HttpConnection* connection, | 45 static net::WebSocket* Create(HttpConnection* connection, |
| 46 const HttpServerRequestInfo& request, | 46 const HttpServerRequestInfo& request, |
| 47 size_t* pos) { | 47 size_t* pos) { |
| 48 if (connection->recv_data().length() < *pos + kWebSocketHandshakeBodyLen) | 48 if (connection->recv_data().length() < *pos + kWebSocketHandshakeBodyLen) |
| 49 return NULL; | 49 return NULL; |
| 50 return new WebSocketHixie76(connection, request, pos); | 50 return new WebSocketHixie76(connection, request, pos); |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 if (socket) | 360 if (socket) |
| 361 return socket; | 361 return socket; |
| 362 | 362 |
| 363 return WebSocketHixie76::Create(connection, request, pos); | 363 return WebSocketHixie76::Create(connection, request, pos); |
| 364 } | 364 } |
| 365 | 365 |
| 366 WebSocket::WebSocket(HttpConnection* connection) : connection_(connection) { | 366 WebSocket::WebSocket(HttpConnection* connection) : connection_(connection) { |
| 367 } | 367 } |
| 368 | 368 |
| 369 } // namespace net | 369 } // namespace net |
| OLD | NEW |