OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "build/build_config.h" | 5 #include "build/build_config.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <windows.h> | 8 #include <windows.h> |
9 #include <shlobj.h> | 9 #include <shlobj.h> |
10 #endif | 10 #endif |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 #include "net/base/upload_bytes_element_reader.h" | 43 #include "net/base/upload_bytes_element_reader.h" |
44 #include "net/base/upload_data_stream.h" | 44 #include "net/base/upload_data_stream.h" |
45 #include "net/base/upload_file_element_reader.h" | 45 #include "net/base/upload_file_element_reader.h" |
46 #include "net/cert/ev_root_ca_metadata.h" | 46 #include "net/cert/ev_root_ca_metadata.h" |
47 #include "net/cert/test_root_certs.h" | 47 #include "net/cert/test_root_certs.h" |
48 #include "net/cookies/cookie_monster.h" | 48 #include "net/cookies/cookie_monster.h" |
49 #include "net/cookies/cookie_store_test_helpers.h" | 49 #include "net/cookies/cookie_store_test_helpers.h" |
50 #include "net/disk_cache/disk_cache.h" | 50 #include "net/disk_cache/disk_cache.h" |
51 #include "net/dns/mock_host_resolver.h" | 51 #include "net/dns/mock_host_resolver.h" |
52 #include "net/ftp/ftp_network_layer.h" | 52 #include "net/ftp/ftp_network_layer.h" |
| 53 #include "net/http/http_byte_range.h" |
53 #include "net/http/http_cache.h" | 54 #include "net/http/http_cache.h" |
54 #include "net/http/http_network_layer.h" | 55 #include "net/http/http_network_layer.h" |
55 #include "net/http/http_network_session.h" | 56 #include "net/http/http_network_session.h" |
56 #include "net/http/http_request_headers.h" | 57 #include "net/http/http_request_headers.h" |
57 #include "net/http/http_response_headers.h" | 58 #include "net/http/http_response_headers.h" |
| 59 #include "net/http/http_util.h" |
58 #include "net/ocsp/nss_ocsp.h" | 60 #include "net/ocsp/nss_ocsp.h" |
59 #include "net/proxy/proxy_service.h" | 61 #include "net/proxy/proxy_service.h" |
60 #include "net/socket/ssl_client_socket.h" | 62 #include "net/socket/ssl_client_socket.h" |
61 #include "net/ssl/ssl_connection_status_flags.h" | 63 #include "net/ssl/ssl_connection_status_flags.h" |
62 #include "net/test/cert_test_util.h" | 64 #include "net/test/cert_test_util.h" |
63 #include "net/test/spawned_test_server/spawned_test_server.h" | 65 #include "net/test/spawned_test_server/spawned_test_server.h" |
64 #include "net/url_request/data_protocol_handler.h" | 66 #include "net/url_request/data_protocol_handler.h" |
65 #include "net/url_request/file_protocol_handler.h" | 67 #include "net/url_request/file_protocol_handler.h" |
66 #include "net/url_request/ftp_protocol_handler.h" | 68 #include "net/url_request/ftp_protocol_handler.h" |
67 #include "net/url_request/static_http_user_agent_settings.h" | 69 #include "net/url_request/static_http_user_agent_settings.h" |
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
753 const size_t content_length = last_byte_position - first_byte_position + 1; | 755 const size_t content_length = last_byte_position - first_byte_position + 1; |
754 std::string partial_buffer_string(buffer.get() + first_byte_position, | 756 std::string partial_buffer_string(buffer.get() + first_byte_position, |
755 buffer.get() + last_byte_position + 1); | 757 buffer.get() + last_byte_position + 1); |
756 | 758 |
757 TestDelegate d; | 759 TestDelegate d; |
758 { | 760 { |
759 URLRequest r(temp_url, DEFAULT_PRIORITY, &d, &default_context_); | 761 URLRequest r(temp_url, DEFAULT_PRIORITY, &d, &default_context_); |
760 | 762 |
761 HttpRequestHeaders headers; | 763 HttpRequestHeaders headers; |
762 headers.SetHeader(HttpRequestHeaders::kRange, | 764 headers.SetHeader(HttpRequestHeaders::kRange, |
763 base::StringPrintf( | 765 net::HttpUtil::PrintRange(net::HttpByteRange::Bounded( |
764 "bytes=%" PRIuS "-%" PRIuS, | 766 first_byte_position, last_byte_position))); |
765 first_byte_position, last_byte_position)); | |
766 r.SetExtraRequestHeaders(headers); | 767 r.SetExtraRequestHeaders(headers); |
767 r.Start(); | 768 r.Start(); |
768 EXPECT_TRUE(r.is_pending()); | 769 EXPECT_TRUE(r.is_pending()); |
769 | 770 |
770 base::RunLoop().Run(); | 771 base::RunLoop().Run(); |
771 EXPECT_TRUE(!r.is_pending()); | 772 EXPECT_TRUE(!r.is_pending()); |
772 EXPECT_EQ(1, d.response_started_count()); | 773 EXPECT_EQ(1, d.response_started_count()); |
773 EXPECT_FALSE(d.received_data_before_response()); | 774 EXPECT_FALSE(d.received_data_before_response()); |
774 EXPECT_EQ(static_cast<int>(content_length), d.bytes_received()); | 775 EXPECT_EQ(static_cast<int>(content_length), d.bytes_received()); |
775 // Don't use EXPECT_EQ, it will print out a lot of garbage if check failed. | 776 // Don't use EXPECT_EQ, it will print out a lot of garbage if check failed. |
(...skipping 20 matching lines...) Expand all Loading... |
796 const size_t last_byte_position = buffer_size - 1; | 797 const size_t last_byte_position = buffer_size - 1; |
797 const size_t content_length = last_byte_position - first_byte_position + 1; | 798 const size_t content_length = last_byte_position - first_byte_position + 1; |
798 std::string partial_buffer_string(buffer.get() + first_byte_position, | 799 std::string partial_buffer_string(buffer.get() + first_byte_position, |
799 buffer.get() + last_byte_position + 1); | 800 buffer.get() + last_byte_position + 1); |
800 | 801 |
801 TestDelegate d; | 802 TestDelegate d; |
802 { | 803 { |
803 URLRequest r(temp_url, DEFAULT_PRIORITY, &d, &default_context_); | 804 URLRequest r(temp_url, DEFAULT_PRIORITY, &d, &default_context_); |
804 | 805 |
805 HttpRequestHeaders headers; | 806 HttpRequestHeaders headers; |
806 headers.SetHeader(HttpRequestHeaders::kRange, | 807 |
807 base::StringPrintf("bytes=%" PRIuS "-", | 808 headers.SetHeader( |
808 first_byte_position)); | 809 HttpRequestHeaders::kRange, |
| 810 net::HttpUtil::PrintRange( |
| 811 net::HttpByteRange::RightUnbounded(first_byte_position))); |
809 r.SetExtraRequestHeaders(headers); | 812 r.SetExtraRequestHeaders(headers); |
810 r.Start(); | 813 r.Start(); |
811 EXPECT_TRUE(r.is_pending()); | 814 EXPECT_TRUE(r.is_pending()); |
812 | 815 |
813 base::RunLoop().Run(); | 816 base::RunLoop().Run(); |
814 EXPECT_TRUE(!r.is_pending()); | 817 EXPECT_TRUE(!r.is_pending()); |
815 EXPECT_EQ(1, d.response_started_count()); | 818 EXPECT_EQ(1, d.response_started_count()); |
816 EXPECT_FALSE(d.received_data_before_response()); | 819 EXPECT_FALSE(d.received_data_before_response()); |
817 EXPECT_EQ(static_cast<int>(content_length), d.bytes_received()); | 820 EXPECT_EQ(static_cast<int>(content_length), d.bytes_received()); |
818 // Don't use EXPECT_EQ, it will print out a lot of garbage if check failed. | 821 // Don't use EXPECT_EQ, it will print out a lot of garbage if check failed. |
(...skipping 13 matching lines...) Expand all Loading... |
832 GURL temp_url = FilePathToFileURL(temp_path); | 835 GURL temp_url = FilePathToFileURL(temp_path); |
833 EXPECT_TRUE(file_util::WriteFile(temp_path, buffer.get(), buffer_size)); | 836 EXPECT_TRUE(file_util::WriteFile(temp_path, buffer.get(), buffer_size)); |
834 | 837 |
835 int64 file_size; | 838 int64 file_size; |
836 EXPECT_TRUE(file_util::GetFileSize(temp_path, &file_size)); | 839 EXPECT_TRUE(file_util::GetFileSize(temp_path, &file_size)); |
837 | 840 |
838 TestDelegate d; | 841 TestDelegate d; |
839 { | 842 { |
840 URLRequest r(temp_url, DEFAULT_PRIORITY, &d, &default_context_); | 843 URLRequest r(temp_url, DEFAULT_PRIORITY, &d, &default_context_); |
841 | 844 |
| 845 std::vector<net::HttpByteRange> ranges; |
| 846 ranges.push_back(net::HttpByteRange::Bounded(0, 0)); |
| 847 ranges.push_back(net::HttpByteRange::Bounded(10, 200)); |
| 848 ranges.push_back(net::HttpByteRange::Bounded(200, 300)); |
| 849 |
842 HttpRequestHeaders headers; | 850 HttpRequestHeaders headers; |
843 headers.SetHeader(HttpRequestHeaders::kRange, | 851 headers.SetHeader(HttpRequestHeaders::kRange, |
844 "bytes=0-0,10-200,200-300"); | 852 HttpUtil::PrintRanges(ranges)); |
845 r.SetExtraRequestHeaders(headers); | 853 r.SetExtraRequestHeaders(headers); |
846 r.Start(); | 854 r.Start(); |
847 EXPECT_TRUE(r.is_pending()); | 855 EXPECT_TRUE(r.is_pending()); |
848 | 856 |
849 base::RunLoop().Run(); | 857 base::RunLoop().Run(); |
850 EXPECT_TRUE(d.request_failed()); | 858 EXPECT_TRUE(d.request_failed()); |
851 } | 859 } |
852 | 860 |
853 EXPECT_TRUE(base::DeleteFile(temp_path, false)); | 861 EXPECT_TRUE(base::DeleteFile(temp_path, false)); |
854 } | 862 } |
(...skipping 6488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7343 | 7351 |
7344 EXPECT_FALSE(r.is_pending()); | 7352 EXPECT_FALSE(r.is_pending()); |
7345 EXPECT_EQ(1, d->response_started_count()); | 7353 EXPECT_EQ(1, d->response_started_count()); |
7346 EXPECT_FALSE(d->received_data_before_response()); | 7354 EXPECT_FALSE(d->received_data_before_response()); |
7347 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size)); | 7355 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size)); |
7348 } | 7356 } |
7349 } | 7357 } |
7350 #endif // !defined(DISABLE_FTP_SUPPORT) | 7358 #endif // !defined(DISABLE_FTP_SUPPORT) |
7351 | 7359 |
7352 } // namespace net | 7360 } // namespace net |
OLD | NEW |