| Index: components/cronet/android/test/native_test_server.cc
|
| diff --git a/components/cronet/android/test/native_test_server.cc b/components/cronet/android/test/native_test_server.cc
|
| index 566421b43515e97369a2ab1c461319da181bfd05..008fd5d764add37635231679900f7abc1eb82412 100644
|
| --- a/components/cronet/android/test/native_test_server.cc
|
| +++ b/components/cronet/android/test/native_test_server.cc
|
| @@ -56,7 +56,27 @@
|
|
|
| net::test_server::EmbeddedTestServer* g_test_server = nullptr;
|
|
|
| -scoped_ptr<net::test_server::RawHttpResponse> ConstructResponseBasedOnFile(
|
| +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(
|
| const base::FilePath& file_path) {
|
| std::string file_contents;
|
| bool read_file = base::ReadFileToString(file_path, &file_contents);
|
| @@ -66,8 +86,8 @@
|
| std::string headers_contents;
|
| bool read_headers = base::ReadFileToString(headers_path, &headers_contents);
|
| DCHECK(read_headers);
|
| - scoped_ptr<net::test_server::RawHttpResponse> http_response(
|
| - new net::test_server::RawHttpResponse(headers_contents, file_contents));
|
| + scoped_ptr<CustomHttpResponse> http_response(
|
| + new CustomHttpResponse(headers_contents, file_contents));
|
| return http_response.Pass();
|
| }
|
|
|
| @@ -130,7 +150,7 @@
|
| if (base::StartsWith(request.relative_url, kSdchPath,
|
| base::CompareCase::SENSITIVE)) {
|
| base::FilePath file_path = dir_path.Append("sdch/index");
|
| - scoped_ptr<net::test_server::RawHttpResponse> response =
|
| + scoped_ptr<CustomHttpResponse> 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.
|
|
|