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> |
| 8 |
7 #include "base/base64.h" | 9 #include "base/base64.h" |
8 #include "base/rand_util.h" | 10 #include "base/rand_util.h" |
9 #include "base/logging.h" | 11 #include "base/logging.h" |
10 #include "base/md5.h" | 12 #include "base/md5.h" |
11 #include "base/sha1.h" | 13 #include "base/sha1.h" |
12 #include "base/string_number_conversions.h" | 14 #include "base/string_number_conversions.h" |
13 #include "base/stringprintf.h" | 15 #include "base/stringprintf.h" |
| 16 #include "base/sys_byteorder.h" |
14 #include "net/server/http_connection.h" | 17 #include "net/server/http_connection.h" |
15 #include "net/server/http_server_request_info.h" | 18 #include "net/server/http_server_request_info.h" |
16 | 19 |
17 #if defined(OS_WIN) | |
18 #include <winsock2.h> | |
19 #else | |
20 #include <arpa/inet.h> | |
21 #endif | |
22 | |
23 #include <limits> | |
24 | |
25 namespace net { | 20 namespace net { |
26 | 21 |
27 namespace { | 22 namespace { |
28 | 23 |
29 static uint32 WebSocketKeyFingerprint(const std::string& str) { | 24 static uint32 WebSocketKeyFingerprint(const std::string& str) { |
30 std::string result; | 25 std::string result; |
31 const char* p_char = str.c_str(); | 26 const char* p_char = str.c_str(); |
32 int length = str.length(); | 27 int length = str.length(); |
33 int spaces = 0; | 28 int spaces = 0; |
34 for (int i = 0; i < length; ++i) { | 29 for (int i = 0; i < length; ++i) { |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 if (socket) | 360 if (socket) |
366 return socket; | 361 return socket; |
367 | 362 |
368 return WebSocketHixie76::Create(connection, request, pos); | 363 return WebSocketHixie76::Create(connection, request, pos); |
369 } | 364 } |
370 | 365 |
371 WebSocket::WebSocket(HttpConnection* connection) : connection_(connection) { | 366 WebSocket::WebSocket(HttpConnection* connection) : connection_(connection) { |
372 } | 367 } |
373 | 368 |
374 } // namespace net | 369 } // namespace net |
OLD | NEW |