| Index: Source/core/loader/DocumentThreadableLoader.cpp
|
| diff --git a/Source/core/loader/DocumentThreadableLoader.cpp b/Source/core/loader/DocumentThreadableLoader.cpp
|
| index 77af89e0b6dfe9d6bb929e12c96cdb081b9e9f21..c12ac96fafe1e63f4362461ee0fd1e2408029356 100644
|
| --- a/Source/core/loader/DocumentThreadableLoader.cpp
|
| +++ b/Source/core/loader/DocumentThreadableLoader.cpp
|
| @@ -45,6 +45,7 @@
|
| #include "core/loader/ThreadableLoaderClient.h"
|
| #include "core/page/ContentSecurityPolicy.h"
|
| #include "core/page/Frame.h"
|
| +#include "core/platform/SharedBuffer.h"
|
| #include "core/platform/network/ResourceError.h"
|
| #include "core/platform/network/ResourceRequest.h"
|
| #include "weborigin/SchemeRegistry.h"
|
| @@ -440,21 +441,19 @@ void DocumentThreadableLoader::loadRequest(const ResourceRequest& request, Secur
|
| return;
|
| }
|
|
|
| - // FIXME: ThreadableLoaderOptions.sniffContent is not supported for synchronous requests.
|
| - Vector<char> data;
|
| - ResourceError error;
|
| - ResourceResponse response;
|
| - unsigned long identifier = std::numeric_limits<unsigned long>::max();
|
| - if (Frame* frame = m_document->frame()) {
|
| - if (!m_document->fetcher()->checkInsecureContent(Resource::Raw, requestURL, options.mixedContentBlockingTreatment)) {
|
| - m_client->didFail(error);
|
| - return;
|
| - }
|
| - identifier = m_document->fetcher()->fetchSynchronously(request, m_options.allowCredentials, error, response, data);
|
| - }
|
| + FetchRequest fetchRequest(request, m_options.initiator, options);
|
| + ResourcePtr<Resource> resource = m_document->fetcher()->fetchSynchronously(fetchRequest);
|
| + ResourceResponse response = resource ? resource->response() : ResourceResponse();
|
| + unsigned long identifier = resource ? resource->identifier() : std::numeric_limits<unsigned long>::max();
|
| + ResourceError error = resource ? resource->resourceError() : ResourceError();
|
|
|
| InspectorInstrumentation::documentThreadableLoaderStartedLoadingForClient(m_document, identifier, m_client);
|
|
|
| + if (!resource) {
|
| + m_client->didFail(error);
|
| + return;
|
| + }
|
| +
|
| // No exception for file:/// resources, see <rdar://problem/4962298>.
|
| // Also, if we have an HTTP response, then it wasn't a network error in fact.
|
| if (!error.isNull() && !requestURL.isLocalFile() && response.httpStatusCode() <= 0) {
|
| @@ -462,7 +461,7 @@ void DocumentThreadableLoader::loadRequest(const ResourceRequest& request, Secur
|
| return;
|
| }
|
|
|
| - // FIXME: FrameLoader::loadSynchronously() does not tell us whether a redirect happened or not, so we guess by comparing the
|
| + // FIXME: A synchronous request does not tell us whether a redirect happened or not, so we guess by comparing the
|
| // request and response URLs. This isn't a perfect test though, since a server can serve a redirect to the same URL that was
|
| // requested. Also comparing the request and response URLs as strings will fail if the requestURL still has its credentials.
|
| if (requestURL != response.url() && (!isAllowedByPolicy(response.url()) || !isAllowedRedirect(response.url()))) {
|
| @@ -472,9 +471,9 @@ void DocumentThreadableLoader::loadRequest(const ResourceRequest& request, Secur
|
|
|
| didReceiveResponse(identifier, response);
|
|
|
| - const char* bytes = static_cast<const char*>(data.data());
|
| - int len = static_cast<int>(data.size());
|
| - didReceiveData(identifier, bytes, len);
|
| + SharedBuffer* data = resource->resourceBuffer();
|
| + if (data)
|
| + didReceiveData(identifier, data->data(), data->size());
|
|
|
| didFinishLoading(identifier, 0.0);
|
| }
|
|
|