| 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> |
| 11 #include <shlobj.h> | 11 #include <shlobj.h> |
| 12 #elif defined(OS_LINUX) | 12 #elif defined(OS_LINUX) |
| 13 #include "base/nss_init.h" | 13 #include "base/nss_init.h" |
| 14 #endif | 14 #endif |
| 15 | 15 |
| 16 #include <algorithm> | 16 #include <algorithm> |
| 17 #include <string> | 17 #include <string> |
| 18 | 18 |
| 19 #include "base/file_util.h" | 19 #include "base/file_util.h" |
| 20 #include "base/format_macros.h" |
| 20 #include "base/message_loop.h" | 21 #include "base/message_loop.h" |
| 21 #include "base/path_service.h" | 22 #include "base/path_service.h" |
| 22 #include "base/process_util.h" | 23 #include "base/process_util.h" |
| 23 #include "base/string_piece.h" | 24 #include "base/string_piece.h" |
| 24 #include "base/string_util.h" | 25 #include "base/string_util.h" |
| 25 #include "net/base/cookie_monster.h" | 26 #include "net/base/cookie_monster.h" |
| 26 #include "net/base/load_flags.h" | 27 #include "net/base/load_flags.h" |
| 27 #include "net/base/load_log.h" | 28 #include "net/base/load_log.h" |
| 28 #include "net/base/load_log_unittest.h" | 29 #include "net/base/load_log_unittest.h" |
| 29 #include "net/base/net_errors.h" | 30 #include "net/base/net_errors.h" |
| (...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 697 const size_t first_byte_position = 500; | 698 const size_t first_byte_position = 500; |
| 698 const size_t last_byte_position = buffer_size - first_byte_position; | 699 const size_t last_byte_position = buffer_size - first_byte_position; |
| 699 const size_t content_length = last_byte_position - first_byte_position + 1; | 700 const size_t content_length = last_byte_position - first_byte_position + 1; |
| 700 std::string partial_buffer_string(buffer.get() + first_byte_position, | 701 std::string partial_buffer_string(buffer.get() + first_byte_position, |
| 701 buffer.get() + last_byte_position + 1); | 702 buffer.get() + last_byte_position + 1); |
| 702 | 703 |
| 703 TestDelegate d; | 704 TestDelegate d; |
| 704 { | 705 { |
| 705 TestURLRequest r(temp_url, &d); | 706 TestURLRequest r(temp_url, &d); |
| 706 | 707 |
| 707 r.SetExtraRequestHeaders(StringPrintf("Range: bytes=%d-%d\n", | 708 r.SetExtraRequestHeaders( |
| 708 first_byte_position, | 709 StringPrintf("Range: bytes=%" PRIuS "-%" PRIuS "\n", |
| 709 last_byte_position)); | 710 first_byte_position, last_byte_position)); |
| 710 r.Start(); | 711 r.Start(); |
| 711 EXPECT_TRUE(r.is_pending()); | 712 EXPECT_TRUE(r.is_pending()); |
| 712 | 713 |
| 713 MessageLoop::current()->Run(); | 714 MessageLoop::current()->Run(); |
| 714 EXPECT_TRUE(!r.is_pending()); | 715 EXPECT_TRUE(!r.is_pending()); |
| 715 EXPECT_EQ(1, d.response_started_count()); | 716 EXPECT_EQ(1, d.response_started_count()); |
| 716 EXPECT_FALSE(d.received_data_before_response()); | 717 EXPECT_FALSE(d.received_data_before_response()); |
| 717 EXPECT_EQ(static_cast<int>(content_length), d.bytes_received()); | 718 EXPECT_EQ(static_cast<int>(content_length), d.bytes_received()); |
| 718 // Don't use EXPECT_EQ, it will print out a lot of garbage if check failed. | 719 // Don't use EXPECT_EQ, it will print out a lot of garbage if check failed. |
| 719 EXPECT_TRUE(partial_buffer_string == d.data_received()); | 720 EXPECT_TRUE(partial_buffer_string == d.data_received()); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 738 const size_t first_byte_position = 500; | 739 const size_t first_byte_position = 500; |
| 739 const size_t last_byte_position = buffer_size - 1; | 740 const size_t last_byte_position = buffer_size - 1; |
| 740 const size_t content_length = last_byte_position - first_byte_position + 1; | 741 const size_t content_length = last_byte_position - first_byte_position + 1; |
| 741 std::string partial_buffer_string(buffer.get() + first_byte_position, | 742 std::string partial_buffer_string(buffer.get() + first_byte_position, |
| 742 buffer.get() + last_byte_position + 1); | 743 buffer.get() + last_byte_position + 1); |
| 743 | 744 |
| 744 TestDelegate d; | 745 TestDelegate d; |
| 745 { | 746 { |
| 746 TestURLRequest r(temp_url, &d); | 747 TestURLRequest r(temp_url, &d); |
| 747 | 748 |
| 748 r.SetExtraRequestHeaders(StringPrintf("Range: bytes=%d-\n", | 749 r.SetExtraRequestHeaders(StringPrintf("Range: bytes=%" PRIuS "-\n", |
| 749 first_byte_position)); | 750 first_byte_position)); |
| 750 r.Start(); | 751 r.Start(); |
| 751 EXPECT_TRUE(r.is_pending()); | 752 EXPECT_TRUE(r.is_pending()); |
| 752 | 753 |
| 753 MessageLoop::current()->Run(); | 754 MessageLoop::current()->Run(); |
| 754 EXPECT_TRUE(!r.is_pending()); | 755 EXPECT_TRUE(!r.is_pending()); |
| 755 EXPECT_EQ(1, d.response_started_count()); | 756 EXPECT_EQ(1, d.response_started_count()); |
| 756 EXPECT_FALSE(d.received_data_before_response()); | 757 EXPECT_FALSE(d.received_data_before_response()); |
| 757 EXPECT_EQ(static_cast<int>(content_length), d.bytes_received()); | 758 EXPECT_EQ(static_cast<int>(content_length), d.bytes_received()); |
| 758 // Don't use EXPECT_EQ, it will print out a lot of garbage if check failed. | 759 // Don't use EXPECT_EQ, it will print out a lot of garbage if check failed. |
| (...skipping 1461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2220 ASSERT_TRUE(NULL != server_.get()); | 2221 ASSERT_TRUE(NULL != server_.get()); |
| 2221 TestDelegate d; | 2222 TestDelegate d; |
| 2222 TestURLRequest | 2223 TestURLRequest |
| 2223 req(server_->TestServerPage("echoheaderoverride?Accept-Charset"), &d); | 2224 req(server_->TestServerPage("echoheaderoverride?Accept-Charset"), &d); |
| 2224 req.set_context(new URLRequestTestContext()); | 2225 req.set_context(new URLRequestTestContext()); |
| 2225 req.SetExtraRequestHeaders("Accept-Charset: koi-8r"); | 2226 req.SetExtraRequestHeaders("Accept-Charset: koi-8r"); |
| 2226 req.Start(); | 2227 req.Start(); |
| 2227 MessageLoop::current()->Run(); | 2228 MessageLoop::current()->Run(); |
| 2228 EXPECT_EQ(std::string("koi-8r"), d.data_received()); | 2229 EXPECT_EQ(std::string("koi-8r"), d.data_received()); |
| 2229 } | 2230 } |
| OLD | NEW |