diff options
-rw-r--r-- | chrome_frame/test/url_request_test.cc | 17 | ||||
-rw-r--r-- | chrome_frame/urlmon_url_request.cc | 4 |
2 files changed, 13 insertions, 8 deletions
diff --git a/chrome_frame/test/url_request_test.cc b/chrome_frame/test/url_request_test.cc index 1393aaa..235b227 100644 --- a/chrome_frame/test/url_request_test.cc +++ b/chrome_frame/test/url_request_test.cc @@ -3,7 +3,9 @@ // found in the LICENSE file. #include <atlbase.h> #include <atlcom.h> + #include "app/win_util.h" +#include "chrome_frame/test/test_server.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock_mutant.h" @@ -104,18 +106,21 @@ TEST(UrlmonUrlRequestTest, Simple1) { // Same as Simple1 except we use the HEAD verb to fetch only the headers // from the server. -// TODO(tommi): Fix and reenable. -TEST(UrlmonUrlRequestTest, DISABLED_Head) { +TEST(UrlmonUrlRequestTest, Head) { MockUrlDelegate mock; - ChromeFrameHTTPServer server; chrome_frame_test::TimedMsgLoop loop; + // Use SimpleWebServer instead of the python server to support HEAD + // requests. + test_server::SimpleWebServer server(13337); + test_server::SimpleResponse head_response("/head", ""); + server.AddResponse(&head_response); + win_util::ScopedCOMInitializer init_com; CComObjectStackEx<UrlmonUrlRequest> request; - server.SetUp(); request.AddRef(); request.Initialize(&mock, 1, // request_id - server.Resolve(L"files/chrome_frame_window_open.html").spec(), + "http://localhost:13337/head", "head", "", // referrer "", // extra request @@ -129,7 +134,6 @@ TEST(UrlmonUrlRequestTest, DISABLED_Head) { .WillOnce(testing::IgnoreResult(testing::InvokeWithoutArgs(CreateFunctor( &request, &UrlmonUrlRequest::Read, 512)))); - // For HEAD requests we don't expect content reads. EXPECT_CALL(mock, OnReadComplete(1, testing::_)).Times(0); @@ -140,7 +144,6 @@ TEST(UrlmonUrlRequestTest, DISABLED_Head) { request.Start(); loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); request.Release(); - server.TearDown(); } TEST(UrlmonUrlRequestTest, UnreachableUrl) { diff --git a/chrome_frame/urlmon_url_request.cc b/chrome_frame/urlmon_url_request.cc index 7f330ab..18b3c39 100644 --- a/chrome_frame/urlmon_url_request.cc +++ b/chrome_frame/urlmon_url_request.cc @@ -478,7 +478,9 @@ STDMETHODIMP UrlmonUrlRequest::OnDataAvailable(DWORD flags, DWORD size, return E_UNEXPECTED; } - pending_data_ = read_stream; + // Some requests such as HEAD have zero data. + if (size > 0) + pending_data_ = read_stream; if (pending_read_size_) { size_t bytes_copied = SendDataToDelegate(pending_read_size_); |