Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5975)

Unified Diff: chrome/test/webdriver/dispatch.cc

Issue 7108037: Revert 88492 - In chromedriver, add /log url to get the contents of the chromedriver log (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/webdriver/dispatch.h ('k') | chrome/test/webdriver/keymap.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/webdriver/dispatch.cc
===================================================================
--- chrome/test/webdriver/dispatch.cc (revision 88495)
+++ chrome/test/webdriver/dispatch.cc (working copy)
@@ -9,9 +9,7 @@
#include <vector>
#include "base/format_macros.h"
-#include "base/json/json_reader.h"
#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
#include "base/message_loop_proxy.h"
#include "base/string_split.h"
#include "base/string_util.h"
@@ -22,16 +20,11 @@
#include "chrome/test/webdriver/commands/command.h"
#include "chrome/test/webdriver/session_manager.h"
#include "chrome/test/webdriver/utility_functions.h"
-#include "chrome/test/webdriver/webdriver_logging.h"
namespace webdriver {
namespace {
-// Maximum safe size of HTTP response message. Any larger than this,
-// the message may not be transferred at all.
-const int kMaxHttpMessageSize = 1024 * 1024 * 16; // 16MB
-
bool ForbidsMessageBody(const std::string& request_method,
const HttpResponse& response) {
return request_method == "HEAD" ||
@@ -66,40 +59,15 @@
shutdown_event->Signal();
}
-void SendOkWithBody(struct mg_connection* connection,
- const std::string& content) {
- const char* response_fmt = "HTTP/1.1 200 OK\r\n"
- "Content-Length:%d\r\n\r\n"
- "%s";
- std::string response = base::StringPrintf(
- response_fmt, content.length(), content.c_str());
+void SendStatus(struct mg_connection* connection,
+ const struct mg_request_info* request_info,
+ void* user_data) {
+ std::string response = "HTTP/1.1 200 OK\r\n"
+ "Content-Length:2\r\n\r\n"
+ "ok";
mg_write(connection, response.data(), response.length());
}
-void SendHealthz(struct mg_connection* connection,
- const struct mg_request_info* request_info,
- void* user_data) {
- SendOkWithBody(connection, "ok");
-}
-
-void SendLog(struct mg_connection* connection,
- const struct mg_request_info* request_info,
- void* user_data) {
- std::string content, log;
- if (GetLogContents(&log)) {
- content = "START ChromeDriver log";
- const int kMaxSizeWithoutHeaders = kMaxHttpMessageSize - 10000;
- if (log.size() > kMaxSizeWithoutHeaders) {
- log = log.substr(log.size() - kMaxSizeWithoutHeaders);
- content += " (only last several MB)";
- }
- content += ":\n" + log + "END ChromeDriver log";
- } else {
- content = "No ChromeDriver log found";
- }
- SendOkWithBody(connection, content);
-}
-
void SendNoContentResponse(struct mg_connection* connection,
const struct mg_request_info* request_info,
void* user_data) {
@@ -131,6 +99,7 @@
"Content-Length:%" PRIuS "\r\n"
"\r\n", body.length());
+ LOG(ERROR) << header << body;
mg_write(connection, header.data(), header.length());
mg_write(connection, body.data(), body.length());
}
@@ -256,24 +225,18 @@
base::SplitString(uri, '/', path_segments);
if (*method == "POST" && request_info->post_data_len > 0) {
+ VLOG(1) << "...parsing request body";
std::string json(request_info->post_data, request_info->post_data_len);
- std::string error_msg;
- scoped_ptr<Value> params(base::JSONReader::ReadAndReturnError(
- json, true, NULL, &error_msg));
- if (!params.get()) {
+ std::string error;
+ if (!ParseJSONDictionary(json, parameters, &error)) {
response->SetError(new Error(
kBadRequest,
- "Failed to parse command data: " + error_msg + "\n Data: " + json));
+ "Failed to parse command data: " + error + "\n Data: " + json));
return false;
}
- if (!params->IsType(Value::TYPE_DICTIONARY)) {
- response->SetError(new Error(
- kBadRequest,
- "Data passed in URL must be a dictionary. Data: " + json));
- return false;
- }
- *parameters = static_cast<DictionaryValue*>(params.release());
}
+ VLOG(1) << "Parsed " << method << " " << uri
+ << std::string(request_info->post_data, request_info->post_data_len);
return true;
}
@@ -320,14 +283,10 @@
shutdown_event);
}
-void Dispatcher::AddHealthz(const std::string& pattern) {
- mg_set_uri_callback(context_, (root_ + pattern).c_str(), &SendHealthz, NULL);
+void Dispatcher::AddStatus(const std::string& pattern) {
+ mg_set_uri_callback(context_, (root_ + pattern).c_str(), &SendStatus, NULL);
}
-void Dispatcher::AddLog(const std::string& pattern) {
- mg_set_uri_callback(context_, (root_ + pattern).c_str(), &SendLog, NULL);
-}
-
void Dispatcher::SetNotImplemented(const std::string& pattern) {
mg_set_uri_callback(context_, (root_ + pattern).c_str(),
&SendNotImplementedError, NULL);
« no previous file with comments | « chrome/test/webdriver/dispatch.h ('k') | chrome/test/webdriver/keymap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698