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" |
58 #include "net/ocsp/nss_ocsp.h" | 59 #include "net/ocsp/nss_ocsp.h" |
59 #include "net/proxy/proxy_service.h" | 60 #include "net/proxy/proxy_service.h" |
60 #include "net/socket/ssl_client_socket.h" | 61 #include "net/socket/ssl_client_socket.h" |
61 #include "net/ssl/ssl_connection_status_flags.h" | 62 #include "net/ssl/ssl_connection_status_flags.h" |
62 #include "net/test/cert_test_util.h" | 63 #include "net/test/cert_test_util.h" |
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
752 const size_t last_byte_position = buffer_size - first_byte_position; | 753 const size_t last_byte_position = buffer_size - first_byte_position; |
753 const size_t content_length = last_byte_position - first_byte_position + 1; | 754 const size_t content_length = last_byte_position - first_byte_position + 1; |
754 std::string partial_buffer_string(buffer.get() + first_byte_position, | 755 std::string partial_buffer_string(buffer.get() + first_byte_position, |
755 buffer.get() + last_byte_position + 1); | 756 buffer.get() + last_byte_position + 1); |
756 | 757 |
757 TestDelegate d; | 758 TestDelegate d; |
758 { | 759 { |
759 URLRequest r(temp_url, DEFAULT_PRIORITY, &d, &default_context_); | 760 URLRequest r(temp_url, DEFAULT_PRIORITY, &d, &default_context_); |
760 | 761 |
761 HttpRequestHeaders headers; | 762 HttpRequestHeaders headers; |
762 headers.SetHeader(HttpRequestHeaders::kRange, | 763 headers.SetHeader( |
763 base::StringPrintf( | 764 HttpRequestHeaders::kRange, |
764 "bytes=%" PRIuS "-%" PRIuS, | 765 net::HttpByteRange::Bounded( |
765 first_byte_position, last_byte_position)); | 766 first_byte_position, last_byte_position).GetHeaderValue()); |
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 21 matching lines...) Expand all Loading... |
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 headers.SetHeader(HttpRequestHeaders::kRange, |
807 base::StringPrintf("bytes=%" PRIuS "-", | 808 net::HttpByteRange::RightUnbounded( |
808 first_byte_position)); | 809 first_byte_position).GetHeaderValue()); |
809 r.SetExtraRequestHeaders(headers); | 810 r.SetExtraRequestHeaders(headers); |
810 r.Start(); | 811 r.Start(); |
811 EXPECT_TRUE(r.is_pending()); | 812 EXPECT_TRUE(r.is_pending()); |
812 | 813 |
813 base::RunLoop().Run(); | 814 base::RunLoop().Run(); |
814 EXPECT_TRUE(!r.is_pending()); | 815 EXPECT_TRUE(!r.is_pending()); |
815 EXPECT_EQ(1, d.response_started_count()); | 816 EXPECT_EQ(1, d.response_started_count()); |
816 EXPECT_FALSE(d.received_data_before_response()); | 817 EXPECT_FALSE(d.received_data_before_response()); |
817 EXPECT_EQ(static_cast<int>(content_length), d.bytes_received()); | 818 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. | 819 // Don't use EXPECT_EQ, it will print out a lot of garbage if check failed. |
(...skipping 14 matching lines...) Expand all Loading... |
833 EXPECT_TRUE(file_util::WriteFile(temp_path, buffer.get(), buffer_size)); | 834 EXPECT_TRUE(file_util::WriteFile(temp_path, buffer.get(), buffer_size)); |
834 | 835 |
835 int64 file_size; | 836 int64 file_size; |
836 EXPECT_TRUE(file_util::GetFileSize(temp_path, &file_size)); | 837 EXPECT_TRUE(file_util::GetFileSize(temp_path, &file_size)); |
837 | 838 |
838 TestDelegate d; | 839 TestDelegate d; |
839 { | 840 { |
840 URLRequest r(temp_url, DEFAULT_PRIORITY, &d, &default_context_); | 841 URLRequest r(temp_url, DEFAULT_PRIORITY, &d, &default_context_); |
841 | 842 |
842 HttpRequestHeaders headers; | 843 HttpRequestHeaders headers; |
843 headers.SetHeader(HttpRequestHeaders::kRange, | 844 headers.SetHeader(HttpRequestHeaders::kRange, "bytes=0-0,10-200,200-300"); |
844 "bytes=0-0,10-200,200-300"); | |
845 r.SetExtraRequestHeaders(headers); | 845 r.SetExtraRequestHeaders(headers); |
846 r.Start(); | 846 r.Start(); |
847 EXPECT_TRUE(r.is_pending()); | 847 EXPECT_TRUE(r.is_pending()); |
848 | 848 |
849 base::RunLoop().Run(); | 849 base::RunLoop().Run(); |
850 EXPECT_TRUE(d.request_failed()); | 850 EXPECT_TRUE(d.request_failed()); |
851 } | 851 } |
852 | 852 |
853 EXPECT_TRUE(base::DeleteFile(temp_path, false)); | 853 EXPECT_TRUE(base::DeleteFile(temp_path, false)); |
854 } | 854 } |
(...skipping 6488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7343 | 7343 |
7344 EXPECT_FALSE(r.is_pending()); | 7344 EXPECT_FALSE(r.is_pending()); |
7345 EXPECT_EQ(1, d->response_started_count()); | 7345 EXPECT_EQ(1, d->response_started_count()); |
7346 EXPECT_FALSE(d->received_data_before_response()); | 7346 EXPECT_FALSE(d->received_data_before_response()); |
7347 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size)); | 7347 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size)); |
7348 } | 7348 } |
7349 } | 7349 } |
7350 #endif // !defined(DISABLE_FTP_SUPPORT) | 7350 #endif // !defined(DISABLE_FTP_SUPPORT) |
7351 | 7351 |
7352 } // namespace net | 7352 } // namespace net |
OLD | NEW |