Chromium Code Reviews| 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 "chrome/test/webdriver/webdriver_dispatch.h" | 5 #include "chrome/test/webdriver/webdriver_dispatch.h" |
| 6 | 6 |
| 7 #include <sstream> | 7 #include <sstream> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 167 break; | 167 break; |
| 168 } | 168 } |
| 169 | 169 |
| 170 case kBadRequest: | 170 case kBadRequest: |
| 171 case kSessionNotFound: | 171 case kSessionNotFound: |
| 172 http_response->set_status(status); | 172 http_response->set_status(status); |
| 173 break; | 173 break; |
| 174 | 174 |
| 175 case kMethodNotAllowed: { | 175 case kMethodNotAllowed: { |
| 176 const Value* const value = command_response.GetValue(); | 176 const Value* const value = command_response.GetValue(); |
| 177 if (!value->IsType(Value::TYPE_LIST)) { | 177 ListValue* list_value = const_cast<Value*>(value)->AsList(); |
|
tony
2011/08/24 19:37:51
Rather than const_cast, we should just change the
tfarina
2011/08/24 20:46:51
Done.
| |
| 178 if (!list_value) { | |
| 178 // This should never happen. | 179 // This should never happen. |
| 179 http_response->set_status(HttpResponse::kInternalServerError); | 180 http_response->set_status(HttpResponse::kInternalServerError); |
| 180 http_response->SetBody( | 181 http_response->SetBody( |
| 181 "Unable to set 'Allow' header: response value was " | 182 "Unable to set 'Allow' header: response value was " |
| 182 "not a list of strings: " + command_response.ToJSON()); | 183 "not a list of strings: " + command_response.ToJSON()); |
| 183 return; | 184 return; |
| 184 } | 185 } |
| 185 | 186 |
| 186 const ListValue* const list_value = | |
| 187 static_cast<const ListValue* const>(value); | |
| 188 std::vector<std::string> allowed_methods; | 187 std::vector<std::string> allowed_methods; |
| 189 for (size_t i = 0; i < list_value->GetSize(); ++i) { | 188 for (size_t i = 0; i < list_value->GetSize(); ++i) { |
| 190 std::string method; | 189 std::string method; |
| 191 if (list_value->GetString(i, &method)) { | 190 if (list_value->GetString(i, &method)) { |
| 192 allowed_methods.push_back(method); | 191 allowed_methods.push_back(method); |
| 193 } else { | 192 } else { |
| 194 // This should never happen. | 193 // This should never happen. |
| 195 http_response->set_status(HttpResponse::kInternalServerError); | 194 http_response->set_status(HttpResponse::kInternalServerError); |
| 196 http_response->SetBody( | 195 http_response->SetBody( |
| 197 "Unable to set 'Allow' header: response value was " | 196 "Unable to set 'Allow' header: response value was " |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 332 void Dispatcher::SetNotImplemented(const std::string& pattern) { | 331 void Dispatcher::SetNotImplemented(const std::string& pattern) { |
| 333 mg_set_uri_callback(context_, (root_ + pattern).c_str(), | 332 mg_set_uri_callback(context_, (root_ + pattern).c_str(), |
| 334 &SendNotImplementedError, NULL); | 333 &SendNotImplementedError, NULL); |
| 335 } | 334 } |
| 336 | 335 |
| 337 void Dispatcher::ForbidAllOtherRequests() { | 336 void Dispatcher::ForbidAllOtherRequests() { |
| 338 mg_set_uri_callback(context_, "*", &SendForbidden, NULL); | 337 mg_set_uri_callback(context_, "*", &SendForbidden, NULL); |
| 339 } | 338 } |
| 340 | 339 |
| 341 } // namespace webdriver | 340 } // namespace webdriver |
| OLD | NEW |