summaryrefslogtreecommitdiffstats
path: root/components/cronet
diff options
context:
space:
mode:
authorsvaldez <svaldez@chromium.org>2015-10-27 08:41:25 -0700
committerCommit bot <commit-bot@chromium.org>2015-10-27 15:42:17 +0000
commit5c265faa70626b7754e8b62300f65771dae2adbf (patch)
treeecebe2e86facbf81c834dcd79e111a4b8f7b2cf8 /components/cronet
parentbefca2c1f96ef13bc0a1530187731985d16cb9bb (diff)
downloadchromium_src-5c265faa70626b7754e8b62300f65771dae2adbf.zip
chromium_src-5c265faa70626b7754e8b62300f65771dae2adbf.tar.gz
chromium_src-5c265faa70626b7754e8b62300f65771dae2adbf.tar.bz2
SSL and add handlers in EmbeddedTestServer
As part of the migration of tests to EmbeddedTestServer, this CL modifies EmbeddedTestServer to support SSLServerSocket and to add shared default handlers that can be used by tests to mirror the SpawnedTestServer handlers. The major changes are: - SSL support through SSLServerSocket - Adding SSLServerConfig to configure SSLServerSockets. - Setting up default handlers for BrowserTestBase tests. - Asynchronous HttpResponse. - Moving EmbeddedTestServer to the net:: namespace. BUG=496825 NOPRESUBMIT=TRUE Review URL: https://codereview.chromium.org/1376593007 Cr-Commit-Position: refs/heads/master@{#356305}
Diffstat (limited to 'components/cronet')
-rw-r--r--components/cronet/android/test/native_test_server.cc28
1 files changed, 4 insertions, 24 deletions
diff --git a/components/cronet/android/test/native_test_server.cc b/components/cronet/android/test/native_test_server.cc
index 008fd5d..566421b 100644
--- a/components/cronet/android/test/native_test_server.cc
+++ b/components/cronet/android/test/native_test_server.cc
@@ -56,27 +56,7 @@ const char kSdchDictPath[] = "/sdch/dict/";
net::test_server::EmbeddedTestServer* g_test_server = nullptr;
-class CustomHttpResponse : public net::test_server::HttpResponse {
- public:
- CustomHttpResponse(const std::string& headers, const std::string& contents)
- : headers_(headers), contents_(contents) {}
-
- std::string ToResponseString() const override {
- return headers_ + "\r\n" + contents_;
- }
-
- void AddHeader(const std::string& key_value_pair) {
- headers_.append(base::StringPrintf("%s\r\n", key_value_pair.c_str()));
- }
-
- private:
- std::string headers_;
- std::string contents_;
-
- DISALLOW_COPY_AND_ASSIGN(CustomHttpResponse);
-};
-
-scoped_ptr<CustomHttpResponse> ConstructResponseBasedOnFile(
+scoped_ptr<net::test_server::RawHttpResponse> ConstructResponseBasedOnFile(
const base::FilePath& file_path) {
std::string file_contents;
bool read_file = base::ReadFileToString(file_path, &file_contents);
@@ -86,8 +66,8 @@ scoped_ptr<CustomHttpResponse> ConstructResponseBasedOnFile(
std::string headers_contents;
bool read_headers = base::ReadFileToString(headers_path, &headers_contents);
DCHECK(read_headers);
- scoped_ptr<CustomHttpResponse> http_response(
- new CustomHttpResponse(headers_contents, file_contents));
+ scoped_ptr<net::test_server::RawHttpResponse> http_response(
+ new net::test_server::RawHttpResponse(headers_contents, file_contents));
return http_response.Pass();
}
@@ -150,7 +130,7 @@ scoped_ptr<net::test_server::HttpResponse> SdchRequestHandler(
if (base::StartsWith(request.relative_url, kSdchPath,
base::CompareCase::SENSITIVE)) {
base::FilePath file_path = dir_path.Append("sdch/index");
- scoped_ptr<CustomHttpResponse> response =
+ scoped_ptr<net::test_server::RawHttpResponse> response =
ConstructResponseBasedOnFile(file_path).Pass();
// Check for query params to see which dictionary to advertise.
// For instance, ?q=dictionaryA will make the server advertise dictionaryA.