本文整理汇总了C++中WebURLResponse类的典型用法代码示例。如果您正苦于以下问题:C++ WebURLResponse类的具体用法?C++ WebURLResponse怎么用?C++ WebURLResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WebURLResponse类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: didNavigateWithNavigationData
void HistoryDelegate::didNavigateWithNavigationData(WebView* webView, WebNavigationData* navigationData, WebFrame* webFrame)
{
if (!gLayoutTestController->dumpHistoryDelegateCallbacks())
return;
const char* url = navigationData->url();
const char* title = navigationData->title();
WebMutableURLRequest* request = navigationData->originalRequest();
const char* httpMethod = request->HTTPMethod();
WebURLResponse* response = navigationData->response();
int statusCode = response->statusCode();
bool hasSubstituteData = navigationData->hasSubstituteData();
const char* clientRedirectSource = navigationData->clientRedirectSource();
bool hasClientRedirect = clientRedirectSource && strlen(clientRedirectSource);
bool wasFailure = hasSubstituteData || (response && statusCode >= 400);
printf("WebView navigated to url \"%s\" with title \"%s\" with HTTP equivalent method \"%s\". The navigation was %s and was %s%s.\n",
url,
title,
httpMethod,
wasFailure ? "a failure" : "successful",
hasClientRedirect ? "a client redirect from " : "not a client redirect",
clientRedirectSource);
}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:31,代码来源:HistoryDelegate.cpp
示例2: TEST_F
TEST_F(WebEmbeddedWorkerImplTest, ScriptNotFound)
{
WebURL scriptURL = URLTestHelpers::toKURL("https://www.example.com/sw-404.js");
WebURLResponse response;
response.initialize();
response.setMIMEType("text/javascript");
response.setHTTPStatusCode(404);
WebURLError error;
error.reason = 1010;
error.domain = "WebEmbeddedWorkerImplTest";
Platform::current()->unitTestSupport()->registerMockedErrorURL(scriptURL, response, error);
m_startData.scriptURL = scriptURL;
EXPECT_CALL(*m_mockClient, workerReadyForInspection())
.Times(1);
m_worker->startWorkerContext(m_startData);
::testing::Mock::VerifyAndClearExpectations(m_mockClient);
// Load the shadow page.
EXPECT_CALL(*m_mockClient, createServiceWorkerNetworkProvider(::testing::_))
.WillOnce(::testing::Return(nullptr));
Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests();
::testing::Mock::VerifyAndClearExpectations(m_mockClient);
// Load the script.
EXPECT_CALL(*m_mockClient, workerScriptLoaded())
.Times(0);
EXPECT_CALL(*m_mockClient, createServiceWorkerProvider())
.Times(0);
EXPECT_CALL(*m_mockClient, workerContextFailedToStart())
.Times(1);
Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests();
::testing::Mock::VerifyAndClearExpectations(m_mockClient);
}
开发者ID:aobzhirov,项目名称:ChromiumGStreamerBackend,代码行数:34,代码来源:WebEmbeddedWorkerImplTest.cpp
示例3: didReceiveResponse
void ResourceLoader::didReceiveResponse(
const WebURLResponse& response,
std::unique_ptr<WebDataConsumerHandle> handle) {
DCHECK(!response.isNull());
m_fetcher->didReceiveResponse(m_resource.get(), response.toResourceResponse(),
std::move(handle));
}
开发者ID:,项目名称:,代码行数:7,代码来源:
示例4: WebURLResponse
WebURLResponse* WebURLResponse::createInstance()
{
WebURLResponse* instance = new WebURLResponse();
// fake an http response - so it has the IWebHTTPURLResponse interface
instance->m_response = ResourceResponse(KURL(ParsedURLString, "http://"), String(), 0, String(), String());
instance->AddRef();
return instance;
}
开发者ID:,项目名称:,代码行数:8,代码来源:
示例5: willSendRequest
void ResourceHandleInternal::willSendRequest(
WebURLLoader*, WebURLRequest& request, const WebURLResponse& response)
{
ASSERT(m_client);
ASSERT(!request.isNull());
ASSERT(!response.isNull());
m_client->willSendRequest(m_owner, request.toMutableResourceRequest(), response.toResourceResponse());
}
开发者ID:mcgrawp,项目名称:webkit-webcl,代码行数:8,代码来源:ResourceHandle.cpp
示例6: didReceiveResponse
void didReceiveResponse(WebURLLoader* loader, const WebURLResponse& response) override
{
m_didReceiveResponse = true;
m_actualResponse = WebURLResponse(response);
EXPECT_EQ(m_expectedLoader, loader);
EXPECT_EQ(m_expectedResponse.url(), response.url());
EXPECT_EQ(m_expectedResponse.httpStatusCode(), response.httpStatusCode());
}
开发者ID:smishenk,项目名称:chromium-crosswalk,代码行数:8,代码来源:AssociatedURLLoaderTest.cpp
示例7: registerRedirect
void registerRedirect(const WebString& fromURL, const WebString& toURL) {
KURL redirectURL(ParsedURLString, fromURL);
WebURLResponse redirectResponse;
redirectResponse.setURL(redirectURL);
redirectResponse.setHTTPStatusCode(301);
redirectResponse.setHTTPHeaderField(HTTPNames::Location, toURL);
redirectResponse.addToEncodedDataLength(kRedirectResponseOverheadBytes);
Platform::current()->getURLLoaderMockFactory()->registerURL(
redirectURL, redirectResponse, "");
}
开发者ID:mirror,项目名称:chromium,代码行数:10,代码来源:ResourceFetcherTest.cpp
示例8: willSendRequest
// WebURLLoaderClient implementation.
void willSendRequest(WebURLLoader* loader, WebURLRequest& newRequest, const WebURLResponse& redirectResponse) override
{
m_willSendRequest = true;
EXPECT_EQ(m_expectedLoader, loader);
EXPECT_EQ(m_expectedNewRequest.url(), newRequest.url());
// Check that CORS simple headers are transferred to the new request.
EXPECT_EQ(m_expectedNewRequest.httpHeaderField("accept"), newRequest.httpHeaderField("accept"));
EXPECT_EQ(m_expectedRedirectResponse.url(), redirectResponse.url());
EXPECT_EQ(m_expectedRedirectResponse.httpStatusCode(), redirectResponse.httpStatusCode());
EXPECT_EQ(m_expectedRedirectResponse.mimeType(), redirectResponse.mimeType());
}
开发者ID:smishenk,项目名称:chromium-crosswalk,代码行数:12,代码来源:AssociatedURLLoaderTest.cpp
示例9: printResponseDescription
void printResponseDescription(WebTestDelegate* delegate, const WebURLResponse& response)
{
if (response.isNull()) {
delegate->printMessage("(null)");
return;
}
string url = response.url().spec();
char data[100];
snprintf(data, sizeof(data), "%d", response. httpStatusCode());
delegate->printMessage(string("<NSURLResponse ") + descriptionSuitableForTestResult(url) + ", http status code " + data + ">");
}
开发者ID:,项目名称:,代码行数:11,代码来源:
示例10: RegisterMockedUrl
KURL RegisterMockedUrl(const std::string& urlRoot, const WTF::String& filename)
{
WebURLResponse response;
response.initialize();
response.setMIMEType("text/html");
WTF::String localPath = m_baseFilePath;
localPath.append(filename);
KURL url = toKURL(urlRoot + filename.utf8().data());
Platform::current()->unitTestSupport()->registerMockedURL(url, response, localPath);
return url;
}
开发者ID:smishenk,项目名称:chromium-crosswalk,代码行数:11,代码来源:AssociatedURLLoaderTest.cpp
示例11: didReceiveResponse
void ResourceHandleInternal::didReceiveResponse(WebURLLoader*, const WebURLResponse& response)
{
ASSERT(m_client);
ASSERT(!response.isNull());
bool isMultipart = response.isMultipartPayload();
bool isValidStateTransition = (m_state == ConnectionStateStarted || m_state == ConnectionStateReceivedResponse);
// In the case of multipart loads, calls to didReceiveData & didReceiveResponse can be interleaved.
if (!isMultipart && !isValidStateTransition)
CRASH();
m_state = ConnectionStateReceivedResponse;
m_client->didReceiveResponse(m_owner, response.toResourceResponse());
}
开发者ID:mcgrawp,项目名称:webkit-webcl,代码行数:12,代码来源:ResourceHandle.cpp
示例12: registerErrorURL
void registerErrorURL(const char* file, int statusCode)
{
WebURLError error;
error.reason = 0xdead + statusCode;
error.domain = "PageSerializerTest";
WebURLResponse response;
response.initialize();
response.setMIMEType("text/html");
response.setHTTPStatusCode(statusCode);
Platform::current()->unitTestSupport()->registerMockedErrorURL(KURL(m_baseUrl, file), response, error);
}
开发者ID:shaoboyan,项目名称:chromium-crosswalk,代码行数:13,代码来源:PageSerializerTest.cpp
示例13: willFollowRedirect
bool ResourceLoader::willFollowRedirect(
WebURLRequest& passedNewRequest,
const WebURLResponse& passedRedirectResponse) {
DCHECK(!passedNewRequest.isNull());
DCHECK(!passedRedirectResponse.isNull());
if (m_isCacheAwareLoadingActivated) {
// Fail as cache miss if cached response is a redirect.
didFail(
ResourceError::cacheMissError(m_resource->lastResourceRequest().url()));
return false;
}
ResourceRequest& newRequest(passedNewRequest.toMutableResourceRequest());
const ResourceResponse& redirectResponse(
passedRedirectResponse.toResourceResponse());
newRequest.setRedirectStatus(
ResourceRequest::RedirectStatus::FollowedRedirect);
const KURL originalURL = newRequest.url();
ResourceRequestBlockedReason blockedReason = m_fetcher->willFollowRedirect(
m_resource.get(), newRequest, redirectResponse);
if (blockedReason != ResourceRequestBlockedReason::None) {
cancelForRedirectAccessCheckError(newRequest.url(), blockedReason);
return false;
}
// ResourceFetcher::willFollowRedirect() may rewrite the URL to
// something else not for rejecting redirect but for other reasons.
// E.g. WebFrameTestClient::willSendRequest() and
// RenderFrameImpl::willSendRequest(). We should reflect the
// rewriting but currently we cannot. So, return false to make the
// redirect fail.
if (newRequest.url() != originalURL) {
cancelForRedirectAccessCheckError(newRequest.url(),
ResourceRequestBlockedReason::Other);
return false;
}
if (!m_resource->willFollowRedirect(newRequest, redirectResponse)) {
cancelForRedirectAccessCheckError(newRequest.url(),
ResourceRequestBlockedReason::Other);
return false;
}
return true;
}
开发者ID:,项目名称:,代码行数:48,代码来源:
示例14: willSendRequest
void BeaconLoader::willSendRequest(WebURLLoader*, WebURLRequest& passedNewRequest, const WebURLResponse& passedRedirectResponse)
{
passedNewRequest.setAllowStoredCredentials(true);
ResourceRequest& newRequest(passedNewRequest.toMutableResourceRequest());
const ResourceResponse& redirectResponse(passedRedirectResponse.toResourceResponse());
ASSERT(!newRequest.isNull());
ASSERT(!redirectResponse.isNull());
String errorDescription;
StoredCredentials withCredentials = AllowStoredCredentials;
ResourceLoaderOptions options;
if (!CrossOriginAccessControl::handleRedirect(m_beaconOrigin.get(), newRequest, redirectResponse, withCredentials, options, errorDescription)) {
if (page() && page()->mainFrame()) {
if (page()->mainFrame()->isLocalFrame()) {
LocalFrame* localFrame = toLocalFrame(page()->mainFrame());
if (localFrame->document())
localFrame->document()->addConsoleMessage(ConsoleMessage::create(JSMessageSource, ErrorMessageLevel, errorDescription));
}
}
// Cancel the load and self destruct.
dispose();
return;
}
// FIXME: http://crbug.com/427429 is needed to correctly propagate
// updates of Origin: following this successful redirect.
}
开发者ID:smishenk,项目名称:chromium-crosswalk,代码行数:27,代码来源:BeaconLoader.cpp
示例15: willFollowRedirect
void ResourceLoader::willFollowRedirect(WebURLLoader*, WebURLRequest& passedNewRequest, const WebURLResponse& passedRedirectResponse)
{
ASSERT(m_state != Terminated);
ResourceRequest& newRequest(applyOptions(passedNewRequest.toMutableResourceRequest()));
ASSERT(!newRequest.isNull());
const ResourceResponse& redirectResponse(passedRedirectResponse.toResourceResponse());
ASSERT(!redirectResponse.isNull());
newRequest.setFollowedRedirect(true);
if (!isManualRedirectFetchRequest(m_resource->resourceRequest()) && !m_fetcher->canAccessRedirect(m_resource, newRequest, redirectResponse, m_options)) {
cancel(ResourceError::cancelledDueToAccessCheckError(newRequest.url()));
return;
}
ASSERT(m_state != Terminated);
applyOptions(newRequest); // canAccessRedirect() can modify m_options so we should re-apply it.
m_fetcher->redirectReceived(m_resource, redirectResponse);
ASSERT(m_state != Terminated);
m_resource->willFollowRedirect(newRequest, redirectResponse);
if (newRequest.isNull() || m_state == Terminated)
return;
m_fetcher->willSendRequest(m_resource->identifier(), newRequest, redirectResponse, m_options.initiatorInfo);
ASSERT(m_state != Terminated);
ASSERT(!newRequest.isNull());
m_resource->updateRequest(newRequest);
m_request = newRequest;
}
开发者ID:joone,项目名称:chromium-crosswalk,代码行数:29,代码来源:ResourceLoader.cpp
示例16: adoptPtr
void ResourceLoader::requestSynchronously()
{
OwnPtr<WebURLLoader> loader = adoptPtr(Platform::current()->createURLLoader());
ASSERT(loader);
// downloadToFile is not supported for synchronous requests.
ASSERT(!m_request.downloadToFile());
ResourcePtr<Resource> protectResource(m_resource);
RELEASE_ASSERT(m_connectionState == ConnectionStateNew);
m_connectionState = ConnectionStateStarted;
WrappedResourceRequest requestIn(m_request);
WebURLResponse responseOut;
responseOut.initialize();
WebURLError errorOut;
WebData dataOut;
loader->loadSynchronously(requestIn, responseOut, errorOut, dataOut);
if (errorOut.reason) {
if (m_state == Terminated) {
// A message dispatched while synchronously fetching the resource
// can bring about the cancellation of this load.
ASSERT(!m_resource);
return;
}
didFail(0, errorOut);
return;
}
didReceiveResponse(0, responseOut);
if (m_state == Terminated)
return;
RefPtr<ResourceLoadInfo> resourceLoadInfo = responseOut.toResourceResponse().resourceLoadInfo();
int64_t encodedDataLength = resourceLoadInfo ? resourceLoadInfo->encodedDataLength : WebURLLoaderClient::kUnknownEncodedDataLength;
// Follow the async case convention of not calling didReceiveData or
// appending data to m_resource if the response body is empty. Copying the
// empty buffer is a noop in most cases, but is destructive in the case of
// a 304, where it will overwrite the cached data we should be reusing.
if (dataOut.size()) {
m_fetcher->didReceiveData(m_resource, dataOut.data(), dataOut.size(), encodedDataLength);
m_resource->setResourceBuffer(dataOut);
}
didFinishLoading(0, monotonicallyIncreasingTime(), encodedDataLength);
}
开发者ID:joone,项目名称:chromium-crosswalk,代码行数:45,代码来源:ResourceLoader.cpp
示例17: WrappedResourceResponse
void AssociatedURLLoader::ClientAdapter::didReceiveResponse(unsigned long, const ResourceResponse& response)
{
// Try to use the original ResourceResponse if possible.
WebURLResponse validatedResponse = WrappedResourceResponse(response);
HTTPResponseHeaderValidator validator(m_options.crossOriginRequestPolicy == WebURLLoaderOptions::CrossOriginRequestPolicyUseAccessControl);
if (!m_options.exposeAllResponseHeaders)
validatedResponse.visitHTTPHeaderFields(&validator);
// If there are blocked headers, copy the response so we can remove them.
const HTTPHeaderSet& blockedHeaders = validator.blockedHeaders();
if (!blockedHeaders.isEmpty()) {
validatedResponse = WebURLResponse(validatedResponse);
HTTPHeaderSet::const_iterator end = blockedHeaders.end();
for (HTTPHeaderSet::const_iterator it = blockedHeaders.begin(); it != end; ++it)
validatedResponse.clearHTTPHeaderField(*it);
}
m_client->didReceiveResponse(m_loader, validatedResponse);
}
开发者ID:rzr,项目名称:Tizen_Crosswalk,代码行数:18,代码来源:AssociatedURLLoader.cpp
示例18: didReceiveResponse
void PingLoader::didReceiveResponse(WebURLLoader*, const WebURLResponse& response)
{
if (LocalFrame* frame = this->frame()) {
TRACE_EVENT_INSTANT1("devtools.timeline", "ResourceFinish", TRACE_EVENT_SCOPE_THREAD, "data", InspectorResourceFinishEvent::data(m_identifier, 0, true));
const ResourceResponse& resourceResponse = response.toResourceResponse();
InspectorInstrumentation::didReceiveResourceResponse(frame, m_identifier, 0, resourceResponse, 0);
didFailLoading(frame);
}
dispose();
}
开发者ID:astojilj,项目名称:chromium-crosswalk,代码行数:10,代码来源:PingLoader.cpp
示例19: didReceiveResponse
void SimNetwork::didReceiveResponse(WebURLLoaderClient* client, WebURLLoader* loader, const WebURLResponse& response)
{
auto it = m_requests.find(response.url().string());
if (it == m_requests.end()) {
client->didReceiveResponse(loader, response);
return;
}
ASSERT(it->value);
m_currentRequest = it->value;
m_currentRequest->didReceiveResponse(client, loader, response);
}
开发者ID:dstockwell,项目名称:blink,代码行数:11,代码来源:SimNetwork.cpp
示例20: ALLOW_UNUSED_LOCAL
void WebAssociatedURLLoaderImpl::ClientAdapter::didReceiveResponse(
unsigned long,
const ResourceResponse& response,
std::unique_ptr<WebDataConsumerHandle> handle) {
ALLOW_UNUSED_LOCAL(handle);
DCHECK(!handle);
if (!m_client)
return;
if (m_options.exposeAllResponseHeaders ||
m_options.crossOriginRequestPolicy !=
WebAssociatedURLLoaderOptions::
CrossOriginRequestPolicyUseAccessControl) {
// Use the original ResourceResponse.
m_client->didReceiveResponse(WrappedResourceResponse(response));
return;
}
HTTPHeaderSet exposedHeaders;
extractCorsExposedHeaderNamesList(response, exposedHeaders);
HTTPHeaderSet blockedHeaders;
for (const auto& header : response.httpHeaderFields()) {
if (FetchUtils::isForbiddenResponseHeaderName(header.key) ||
(!isOnAccessControlResponseHeaderWhitelist(header.key) &&
!exposedHeaders.contains(header.key)))
blockedHeaders.add(header.key);
}
if (blockedHeaders.isEmpty()) {
// Use the original ResourceResponse.
m_client->didReceiveResponse(WrappedResourceResponse(response));
return;
}
// If there are blocked headers, copy the response so we can remove them.
WebURLResponse validatedResponse = WrappedResourceResponse(response);
for (const auto& header : blockedHeaders)
validatedResponse.clearHTTPHeaderField(header);
m_client->didReceiveResponse(validatedResponse);
}
开发者ID:,项目名称:,代码行数:40,代码来源:
注:本文中的WebURLResponse类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论