| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/cronet/android/test/native_test_server.h" | 5 #include "components/cronet/android/test/native_test_server.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 if (base::StartsWith(request.relative_url, kSdchPath, | 157 if (base::StartsWith(request.relative_url, kSdchPath, |
| 158 base::CompareCase::SENSITIVE)) { | 158 base::CompareCase::SENSITIVE)) { |
| 159 base::FilePath file_path = dir_path.Append("sdch/index"); | 159 base::FilePath file_path = dir_path.Append("sdch/index"); |
| 160 std::unique_ptr<net::test_server::RawHttpResponse> response = | 160 std::unique_ptr<net::test_server::RawHttpResponse> response = |
| 161 ConstructResponseBasedOnFile(file_path); | 161 ConstructResponseBasedOnFile(file_path); |
| 162 // Check for query params to see which dictionary to advertise. | 162 // Check for query params to see which dictionary to advertise. |
| 163 // For instance, ?q=dictionaryA will make the server advertise dictionaryA. | 163 // For instance, ?q=dictionaryA will make the server advertise dictionaryA. |
| 164 GURL url = g_test_server->GetURL(request.relative_url); | 164 GURL url = g_test_server->GetURL(request.relative_url); |
| 165 std::string dictionary; | 165 std::string dictionary; |
| 166 if (!net::GetValueForKeyInQuery(url, "q", &dictionary)) { | 166 if (!net::GetValueForKeyInQuery(url, "q", &dictionary)) { |
| 167 CHECK(false) << "dictionary is not found in query params of " | 167 // dictionary is not found in query params of |request.relative_url| |
| 168 << request.relative_url; | 168 CHECK(false); |
| 169 } | 169 } |
| 170 auto accept_encoding_header = request.headers.find("Accept-Encoding"); | 170 auto accept_encoding_header = request.headers.find("Accept-Encoding"); |
| 171 if (accept_encoding_header != request.headers.end()) { | 171 if (accept_encoding_header != request.headers.end()) { |
| 172 if (accept_encoding_header->second.find("sdch") != std::string::npos) | 172 if (accept_encoding_header->second.find("sdch") != std::string::npos) |
| 173 response->AddHeader(base::StringPrintf( | 173 response->AddHeader(base::StringPrintf( |
| 174 "Get-Dictionary: %s%s", kSdchDictPath, dictionary.c_str())); | 174 "Get-Dictionary: %s%s", kSdchDictPath, dictionary.c_str())); |
| 175 } | 175 } |
| 176 return std::move(response); | 176 return std::move(response); |
| 177 } | 177 } |
| 178 | 178 |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 #else | 321 #else |
| 322 return JNI_FALSE; | 322 return JNI_FALSE; |
| 323 #endif | 323 #endif |
| 324 } | 324 } |
| 325 | 325 |
| 326 bool RegisterNativeTestServer(JNIEnv* env) { | 326 bool RegisterNativeTestServer(JNIEnv* env) { |
| 327 return RegisterNativesImpl(env); | 327 return RegisterNativesImpl(env); |
| 328 } | 328 } |
| 329 | 329 |
| 330 } // namespace cronet | 330 } // namespace cronet |
| OLD | NEW |