OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/test/test_server.h" | 5 #include "net/test/test_server.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
12 | 12 |
13 #if defined(OS_MACOSX) | 13 #if defined(OS_MACOSX) |
14 #include "net/base/x509_certificate.h" | 14 #include "net/base/x509_certificate.h" |
15 #endif | 15 #endif |
16 | 16 |
17 #include "base/base64.h" | 17 #include "base/base64.h" |
18 #include "base/command_line.h" | 18 #include "base/command_line.h" |
19 #include "base/debug/leak_annotations.h" | 19 #include "base/debug/leak_annotations.h" |
| 20 #include "base/json/json_reader.h" |
20 #include "base/file_util.h" | 21 #include "base/file_util.h" |
21 #include "base/logging.h" | 22 #include "base/logging.h" |
22 #include "base/path_service.h" | 23 #include "base/path_service.h" |
| 24 #include "base/scoped_ptr.h" |
23 #include "base/string_number_conversions.h" | 25 #include "base/string_number_conversions.h" |
24 #include "base/utf_string_conversions.h" | 26 #include "base/utf_string_conversions.h" |
| 27 #include "base/values.h" |
25 #include "googleurl/src/gurl.h" | 28 #include "googleurl/src/gurl.h" |
26 #include "net/base/cert_test_util.h" | 29 #include "net/base/cert_test_util.h" |
27 #include "net/base/host_port_pair.h" | 30 #include "net/base/host_port_pair.h" |
28 #include "net/base/host_resolver.h" | 31 #include "net/base/host_resolver.h" |
29 #include "net/base/test_completion_callback.h" | 32 #include "net/base/test_completion_callback.h" |
30 #include "net/socket/tcp_client_socket.h" | 33 #include "net/socket/tcp_client_socket.h" |
31 #include "net/test/python_utils.h" | 34 #include "net/test/python_utils.h" |
32 #include "testing/platform_test.h" | 35 #include "testing/platform_test.h" |
33 | 36 |
34 namespace net { | 37 namespace net { |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 command_line->AppendSwitchASCII(kBulkCipherSwitch, "aes128"); | 374 command_line->AppendSwitchASCII(kBulkCipherSwitch, "aes128"); |
372 if (https_options_.bulk_ciphers & HTTPSOptions::BULK_CIPHER_AES256) | 375 if (https_options_.bulk_ciphers & HTTPSOptions::BULK_CIPHER_AES256) |
373 command_line->AppendSwitchASCII(kBulkCipherSwitch, "aes256"); | 376 command_line->AppendSwitchASCII(kBulkCipherSwitch, "aes256"); |
374 if (https_options_.bulk_ciphers & HTTPSOptions::BULK_CIPHER_3DES) | 377 if (https_options_.bulk_ciphers & HTTPSOptions::BULK_CIPHER_3DES) |
375 command_line->AppendSwitchASCII(kBulkCipherSwitch, "3des"); | 378 command_line->AppendSwitchASCII(kBulkCipherSwitch, "3des"); |
376 } | 379 } |
377 | 380 |
378 return true; | 381 return true; |
379 } | 382 } |
380 | 383 |
| 384 bool TestServer::ParseServerData(const std::string& server_data) { |
| 385 VLOG(1) << "Server data: " << server_data; |
| 386 base::JSONReader json_reader; |
| 387 scoped_ptr<Value> value(json_reader.JsonToValue(server_data, true, false)); |
| 388 if (!value.get() || |
| 389 !value->IsType(Value::TYPE_DICTIONARY)) { |
| 390 LOG(ERROR) << "Could not parse server data: " |
| 391 << json_reader.GetErrorMessage(); |
| 392 return false; |
| 393 } |
| 394 DictionaryValue* dict = static_cast<DictionaryValue*>(value.get()); |
| 395 int port = 0; |
| 396 if (!dict->GetInteger("port", &port)) { |
| 397 LOG(ERROR) << "Could not find port value"; |
| 398 return false; |
| 399 } |
| 400 if ((port <= 0) || (port >= kuint16max)) { |
| 401 LOG(ERROR) << "Invalid port value: " << port; |
| 402 return false; |
| 403 } |
| 404 host_port_pair_.set_port(port); |
| 405 return true; |
| 406 } |
| 407 |
381 } // namespace net | 408 } // namespace net |
OLD | NEW |