OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 "net/url_request/url_request_unittest.h" | 5 #include "net/url_request/url_request_unittest.h" |
6 | 6 |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 | 8 |
9 #if defined(OS_WIN) | 9 #if defined(OS_WIN) |
10 #include <windows.h> | 10 #include <windows.h> |
(...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
824 EXPECT_TRUE(headers->GetNormalizedHeader("content-type", &header)); | 824 EXPECT_TRUE(headers->GetNormalizedHeader("content-type", &header)); |
825 EXPECT_EQ("text/html; charset=ISO-8859-1", header); | 825 EXPECT_EQ("text/html; charset=ISO-8859-1", header); |
826 | 826 |
827 // The response has two "X-Multiple-Entries" headers. | 827 // The response has two "X-Multiple-Entries" headers. |
828 // This verfies our output has them concatenated together. | 828 // This verfies our output has them concatenated together. |
829 header.clear(); | 829 header.clear(); |
830 EXPECT_TRUE(headers->GetNormalizedHeader("x-multiple-entries", &header)); | 830 EXPECT_TRUE(headers->GetNormalizedHeader("x-multiple-entries", &header)); |
831 EXPECT_EQ("a, b", header); | 831 EXPECT_EQ("a, b", header); |
832 } | 832 } |
833 | 833 |
834 TEST_F(URLRequestTest, BZip2ContentTest) { | 834 // TODO(jar): 14801 Remove BZIP code completely. |
| 835 TEST_F(URLRequestTest, DISABLED_BZip2ContentTest) { |
835 scoped_refptr<HTTPTestServer> server = | 836 scoped_refptr<HTTPTestServer> server = |
836 HTTPTestServer::CreateServer(L"net/data/filter_unittests", NULL); | 837 HTTPTestServer::CreateServer(L"net/data/filter_unittests", NULL); |
837 ASSERT_TRUE(NULL != server.get()); | 838 ASSERT_TRUE(NULL != server.get()); |
838 | 839 |
839 // for localhost domain, we also should support bzip2 encoding | 840 // for localhost domain, we also should support bzip2 encoding |
840 // first, get the original file | 841 // first, get the original file |
841 TestDelegate d1; | 842 TestDelegate d1; |
842 TestURLRequest req1(server->TestServerPage("realfiles/google.txt"), &d1); | 843 TestURLRequest req1(server->TestServerPage("realfiles/google.txt"), &d1); |
843 req1.Start(); | 844 req1.Start(); |
844 MessageLoop::current()->Run(); | 845 MessageLoop::current()->Run(); |
845 | 846 |
846 const std::string& got_content = d1.data_received(); | 847 const std::string& got_content = d1.data_received(); |
847 | 848 |
848 // second, get bzip2 content | 849 // second, get bzip2 content |
849 TestDelegate d2; | 850 TestDelegate d2; |
850 TestURLRequest req2(server->TestServerPage("realbz2files/google.txt"), &d2); | 851 TestURLRequest req2(server->TestServerPage("realbz2files/google.txt"), &d2); |
851 req2.Start(); | 852 req2.Start(); |
852 MessageLoop::current()->Run(); | 853 MessageLoop::current()->Run(); |
853 | 854 |
854 const std::string& got_bz2_content = d2.data_received(); | 855 const std::string& got_bz2_content = d2.data_received(); |
855 | 856 |
856 // compare those two results | 857 // compare those two results |
857 EXPECT_EQ(got_content, got_bz2_content); | 858 EXPECT_EQ(got_content, got_bz2_content); |
858 } | 859 } |
859 | 860 |
860 TEST_F(URLRequestTest, BZip2ContentTest_IncrementalHeader) { | 861 // TODO(jar): 14801 Remove BZIP code completely. |
| 862 TEST_F(URLRequestTest, DISABLED_BZip2ContentTest_IncrementalHeader) { |
861 scoped_refptr<HTTPTestServer> server = | 863 scoped_refptr<HTTPTestServer> server = |
862 HTTPTestServer::CreateServer(L"net/data/filter_unittests", NULL); | 864 HTTPTestServer::CreateServer(L"net/data/filter_unittests", NULL); |
863 ASSERT_TRUE(NULL != server.get()); | 865 ASSERT_TRUE(NULL != server.get()); |
864 | 866 |
865 // for localhost domain, we also should support bzip2 encoding | 867 // for localhost domain, we also should support bzip2 encoding |
866 // first, get the original file | 868 // first, get the original file |
867 TestDelegate d1; | 869 TestDelegate d1; |
868 TestURLRequest req1(server->TestServerPage("realfiles/google.txt"), &d1); | 870 TestURLRequest req1(server->TestServerPage("realfiles/google.txt"), &d1); |
869 req1.Start(); | 871 req1.Start(); |
870 MessageLoop::current()->Run(); | 872 MessageLoop::current()->Run(); |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1230 // Set headers (some of which are specific to the POST). | 1232 // Set headers (some of which are specific to the POST). |
1231 // ("Content-Length: 10" is just a junk value to make sure it gets stripped). | 1233 // ("Content-Length: 10" is just a junk value to make sure it gets stripped). |
1232 req.SetExtraRequestHeaders( | 1234 req.SetExtraRequestHeaders( |
1233 "Content-Type: multipart/form-data; " | 1235 "Content-Type: multipart/form-data; " |
1234 "boundary=----WebKitFormBoundaryAADeAA+NAAWMAAwZ\r\n" | 1236 "boundary=----WebKitFormBoundaryAADeAA+NAAWMAAwZ\r\n" |
1235 "Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9," | 1237 "Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9," |
1236 "text/plain;q=0.8,image/png,*/*;q=0.5\r\n" | 1238 "text/plain;q=0.8,image/png,*/*;q=0.5\r\n" |
1237 "Accept-Language: en-US,en\r\n" | 1239 "Accept-Language: en-US,en\r\n" |
1238 "Accept-Charset: ISO-8859-1,*,utf-8\r\n" | 1240 "Accept-Charset: ISO-8859-1,*,utf-8\r\n" |
1239 "Content-Length: 10\r\n" | 1241 "Content-Length: 10\r\n" |
1240 "Origin: http://localhost:1337/" | 1242 "Origin: http://localhost:1337/"); |
1241 ); | |
1242 req.Start(); | 1243 req.Start(); |
1243 MessageLoop::current()->Run(); | 1244 MessageLoop::current()->Run(); |
1244 | 1245 |
1245 std::string mime_type; | 1246 std::string mime_type; |
1246 req.GetMimeType(&mime_type); | 1247 req.GetMimeType(&mime_type); |
1247 EXPECT_EQ("text/html", mime_type); | 1248 EXPECT_EQ("text/html", mime_type); |
1248 | 1249 |
1249 const std::string& data = d.data_received(); | 1250 const std::string& data = d.data_received(); |
1250 | 1251 |
1251 // Check that the post-specific headers were stripped: | 1252 // Check that the post-specific headers were stripped: |
(...skipping 16 matching lines...) Expand all Loading... |
1268 &d); | 1269 &d); |
1269 req.set_method("POST"); | 1270 req.set_method("POST"); |
1270 req.Start(); | 1271 req.Start(); |
1271 MessageLoop::current()->Run(); | 1272 MessageLoop::current()->Run(); |
1272 EXPECT_EQ(req.method(), "POST"); | 1273 EXPECT_EQ(req.method(), "POST"); |
1273 } | 1274 } |
1274 | 1275 |
1275 // Custom URLRequestJobs for use with interceptor tests | 1276 // Custom URLRequestJobs for use with interceptor tests |
1276 class RestartTestJob : public URLRequestTestJob { | 1277 class RestartTestJob : public URLRequestTestJob { |
1277 public: | 1278 public: |
1278 RestartTestJob(URLRequest* request) : URLRequestTestJob(request, true) {} | 1279 explicit RestartTestJob(URLRequest* request) |
| 1280 : URLRequestTestJob(request, true) {} |
1279 protected: | 1281 protected: |
1280 virtual void StartAsync() { | 1282 virtual void StartAsync() { |
1281 this->NotifyRestartRequired(); | 1283 this->NotifyRestartRequired(); |
1282 } | 1284 } |
1283 }; | 1285 }; |
1284 | 1286 |
1285 class CancelTestJob : public URLRequestTestJob { | 1287 class CancelTestJob : public URLRequestTestJob { |
1286 public: | 1288 public: |
1287 CancelTestJob(URLRequest* request) : URLRequestTestJob(request, true) {} | 1289 explicit CancelTestJob(URLRequest* request) |
| 1290 : URLRequestTestJob(request, true) {} |
1288 protected: | 1291 protected: |
1289 virtual void StartAsync() { | 1292 virtual void StartAsync() { |
1290 request_->Cancel(); | 1293 request_->Cancel(); |
1291 } | 1294 } |
1292 }; | 1295 }; |
1293 | 1296 |
1294 class CancelThenRestartTestJob : public URLRequestTestJob { | 1297 class CancelThenRestartTestJob : public URLRequestTestJob { |
1295 public: | 1298 public: |
1296 CancelThenRestartTestJob(URLRequest* request) | 1299 explicit CancelThenRestartTestJob(URLRequest* request) |
1297 : URLRequestTestJob(request, true) { | 1300 : URLRequestTestJob(request, true) { |
1298 } | 1301 } |
1299 protected: | 1302 protected: |
1300 virtual void StartAsync() { | 1303 virtual void StartAsync() { |
1301 request_->Cancel(); | 1304 request_->Cancel(); |
1302 this->NotifyRestartRequired(); | 1305 this->NotifyRestartRequired(); |
1303 } | 1306 } |
1304 }; | 1307 }; |
1305 | 1308 |
1306 // An Interceptor for use with interceptor tests | 1309 // An Interceptor for use with interceptor tests |
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1822 | 1825 |
1823 int64 file_size = 0; | 1826 int64 file_size = 0; |
1824 file_util::GetFileSize(app_path, &file_size); | 1827 file_util::GetFileSize(app_path, &file_size); |
1825 | 1828 |
1826 EXPECT_TRUE(!r.is_pending()); | 1829 EXPECT_TRUE(!r.is_pending()); |
1827 EXPECT_EQ(1, d.response_started_count()); | 1830 EXPECT_EQ(1, d.response_started_count()); |
1828 EXPECT_FALSE(d.received_data_before_response()); | 1831 EXPECT_FALSE(d.received_data_before_response()); |
1829 EXPECT_EQ(d.bytes_received(), 0); | 1832 EXPECT_EQ(d.bytes_received(), 0); |
1830 } | 1833 } |
1831 } | 1834 } |
OLD | NEW |