diff options
author | tommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-23 21:10:08 +0000 |
---|---|---|
committer | tommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-23 21:10:08 +0000 |
commit | 6f3ad64a8dae4529cd88358f6d91d8750b836367 (patch) | |
tree | 9a06d8854caeb2131e12f21b24e56cb9606c5ddd | |
parent | d999c7c3f4bd9c7c779b4c06ee148d3d0d227e60 (diff) | |
download | chromium_src-6f3ad64a8dae4529cd88358f6d91d8750b836367.zip chromium_src-6f3ad64a8dae4529cd88358f6d91d8750b836367.tar.gz chromium_src-6f3ad64a8dae4529cd88358f6d91d8750b836367.tar.bz2 |
Adding support for HEAD requests.
TEST=Http HEAD requests are now supported for IE.
BUG=none
Review URL: http://codereview.chromium.org/1186002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42382 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome_frame/test/url_request_test.cc | 40 | ||||
-rw-r--r-- | chrome_frame/urlmon_url_request.cc | 20 |
2 files changed, 56 insertions, 4 deletions
diff --git a/chrome_frame/test/url_request_test.cc b/chrome_frame/test/url_request_test.cc index 03428e5..971f239c 100644 --- a/chrome_frame/test/url_request_test.cc +++ b/chrome_frame/test/url_request_test.cc @@ -85,6 +85,46 @@ TEST(UrlmonUrlRequestTest, Simple1) { server.TearDown(); } +// Same as Simple1 except we use the HEAD verb to fetch only the headers +// from the server. +TEST(UrlmonUrlRequestTest, Head) { + MockUrlDelegate mock; + ChromeFrameHTTPServer server; + chrome_frame_test::TimedMsgLoop loop; + 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(), + "head", + "", // referrer + "", // extra request + NULL, // upload data + true); // frame busting + + testing::InSequence s; + EXPECT_CALL(mock, OnResponseStarted(1, testing::_, testing::_, testing::_, + testing::_, testing::_, testing::_)) + .Times(1) + .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::_, testing::_)).Times(0); + + EXPECT_CALL(mock, OnResponseEnd(1, testing::_)) + .Times(1) + .WillOnce(QUIT_LOOP_SOON(loop, 2)); + + request.Start(); + loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); + request.Release(); + server.TearDown(); +} + TEST(UrlmonUrlRequestTest, UnreachableUrl) { MockUrlDelegate mock; chrome_frame_test::TimedMsgLoop loop; diff --git a/chrome_frame/urlmon_url_request.cc b/chrome_frame/urlmon_url_request.cc index 96666a9..1095838 100644 --- a/chrome_frame/urlmon_url_request.cc +++ b/chrome_frame/urlmon_url_request.cc @@ -146,6 +146,8 @@ HRESULT UrlmonUrlRequest::SetRequestData(RequestData* data) { void UrlmonUrlRequest::StealMoniker(IMoniker** moniker) { // Could be called in any thread. There should be no race // since moniker_ is not released while we are in manager's request map. + DLOG(INFO) << __FUNCTION__ << " id: " << id(); + DLOG_IF(WARNING, moniker == NULL) << __FUNCTION__ << " no moniker"; *moniker = moniker_.Detach(); } @@ -311,6 +313,12 @@ STDMETHODIMP UrlmonUrlRequest::GetBindInfo(DWORD* bind_flags, } else if (LowerCaseEqualsASCII(method(), "put")) { bind_info->dwBindVerb = BINDVERB_PUT; upload_data = true; + } else if (LowerCaseEqualsASCII(method(), "head")) { + std::wstring verb(ASCIIToWide(StringToUpperASCII(method()))); + bind_info->dwBindVerb = BINDVERB_CUSTOM; + bind_info->szCustomVerb = reinterpret_cast<wchar_t*>( + ::CoTaskMemAlloc((verb.length() + 1) * sizeof(wchar_t))); + lstrcpyW(bind_info->szCustomVerb, verb.c_str()); } else { NOTREACHED() << "Unknown HTTP method."; status_.set_result(URLRequestStatus::FAILED, net::ERR_METHOD_NOT_SUPPORTED); @@ -912,14 +920,14 @@ void UrlmonUrlRequestManager::StartRequestWorker(int request_id, } void UrlmonUrlRequestManager::ReadRequest(int request_id, int bytes_to_read) { - DLOG(INFO) << __FUNCTION__; + DLOG(INFO) << __FUNCTION__ << " id: " << request_id; ExecuteInWorkerThread(FROM_HERE, NewRunnableMethod(this, &UrlmonUrlRequestManager::ReadRequestWorker, request_id, bytes_to_read)); } void UrlmonUrlRequestManager::ReadRequestWorker(int request_id, int bytes_to_read) { - DLOG(INFO) << __FUNCTION__; + DLOG(INFO) << __FUNCTION__ << " id: " << request_id; DCHECK_EQ(worker_thread_.thread_id(), PlatformThread::CurrentId()); scoped_refptr<UrlmonUrlRequest> request = LookupRequest(request_id); // if zero, it may just have had network error. @@ -929,13 +937,13 @@ void UrlmonUrlRequestManager::ReadRequestWorker(int request_id, } void UrlmonUrlRequestManager::EndRequest(int request_id) { - DLOG(INFO) << __FUNCTION__; + DLOG(INFO) << __FUNCTION__ << " id: " << request_id; ExecuteInWorkerThread(FROM_HERE, NewRunnableMethod(this, &UrlmonUrlRequestManager::EndRequestWorker, request_id)); } void UrlmonUrlRequestManager::EndRequestWorker(int request_id) { - DLOG(INFO) << __FUNCTION__; + DLOG(INFO) << __FUNCTION__ << " id: " << request_id; DCHECK_EQ(worker_thread_.thread_id(), PlatformThread::CurrentId()); scoped_refptr<UrlmonUrlRequest> request = LookupRequest(request_id); if (request) { @@ -1068,7 +1076,11 @@ void UrlmonUrlRequestManager::StealMonikerFromRequestWorker(int request_id, if (request) { request->StealMoniker(moniker); request->Stop(); + } else { + DLOG(INFO) << __FUNCTION__ << " request not found."; } + } else { + DLOG(INFO) << __FUNCTION__ << " request stopping."; } done->Signal(); |