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 #ifndef CHROME_TEST_WEBDRIVER_DISPATCH_H_ | 5 #ifndef CHROME_TEST_WEBDRIVER_DISPATCH_H_ |
6 #define CHROME_TEST_WEBDRIVER_DISPATCH_H_ | 6 #define CHROME_TEST_WEBDRIVER_DISPATCH_H_ |
7 | 7 |
8 #include <sstream> | 8 #include <sstream> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 | 47 |
48 std::string method(request_info->request_method); | 48 std::string method(request_info->request_method); |
49 | 49 |
50 std::vector<std::string> path_segments; | 50 std::vector<std::string> path_segments; |
51 std::string uri(request_info->uri); | 51 std::string uri(request_info->uri); |
52 base::SplitString(uri, '/', &path_segments); | 52 base::SplitString(uri, '/', &path_segments); |
53 | 53 |
54 DictionaryValue* parameters = NULL; | 54 DictionaryValue* parameters = NULL; |
55 if ((method == "POST" || method == "PUT") && | 55 if ((method == "POST" || method == "PUT") && |
56 request_info->post_data_len > 0) { | 56 request_info->post_data_len > 0) { |
57 LOG(INFO) << "...parsing request body"; | 57 VLOG(1) << "...parsing request body"; |
58 std::string json(request_info->post_data, request_info->post_data_len); | 58 std::string json(request_info->post_data, request_info->post_data_len); |
59 std::string error; | 59 std::string error; |
60 if (!ParseJSONDictionary(json, ¶meters, &error)) { | 60 if (!ParseJSONDictionary(json, ¶meters, &error)) { |
61 response.set_value(Value::CreateStringValue( | 61 response.set_value(Value::CreateStringValue( |
62 "Failed to parse command data: " + error + "\n Data: " + json)); | 62 "Failed to parse command data: " + error + "\n Data: " + json)); |
63 response.set_status(kBadRequest); | 63 response.set_status(kBadRequest); |
64 SendResponse(connection, request_info, response); | 64 SendResponse(connection, request_info, response); |
65 return; | 65 return; |
66 } | 66 } |
67 } | 67 } |
68 | 68 |
69 LOG(INFO) << "Dispatching " << method << " " << uri | 69 VLOG(1) << "Dispatching " << method << " " << uri |
70 << std::string(request_info->post_data, | 70 << std::string(request_info->post_data, request_info->post_data_len); |
71 request_info->post_data_len) << std::endl; | |
72 scoped_ptr<CommandType> ptr(new CommandType(path_segments, parameters)); | 71 scoped_ptr<CommandType> ptr(new CommandType(path_segments, parameters)); |
73 DispatchCommand(ptr.get(), method, &response); | 72 DispatchCommand(ptr.get(), method, &response); |
74 SendResponse(connection, request_info, response); | 73 SendResponse(connection, request_info, response); |
75 } | 74 } |
76 | 75 |
77 } // namespace webdriver | 76 } // namespace webdriver |
78 | 77 |
79 #endif // CHROME_TEST_WEBDRIVER_DISPATCH_H_ | 78 #endif // CHROME_TEST_WEBDRIVER_DISPATCH_H_ |
80 | 79 |
OLD | NEW |