+2006-10-29 Maciej Stachowiak <mjs@apple.com>
+
+ Reviewed by Anders.
+
+ - added ResourceResponse class and didReceiveResponse delegate call
+
+ * WebCore.xcodeproj/project.pbxproj: Added new files.
+ * bridge/mac/WebCoreFrameBridge.h: Removed no longer needed
+ expiresTimeForResponse: method.
+ * dom/XMLTokenizer.cpp:
+ (WebCore::openFunc): Updated to use ResourceResponse.
+ * loader/FrameLoader.h: Update loadResourceSynchronously to
+ use ResourceResponse.
+ * loader/LoaderFunctions.h:
+ * loader/icon/IconLoader.cpp:
+ (IconLoader::didReceiveResponse): Updated from receivedResponse
+ and made cross-platform.
+ * loader/icon/IconLoader.h: updated for above change
+ * loader/loader.cpp:
+ (WebCore::Loader::receivedResponse): reduced to just saving
+ the PlatformResponse (ideally we'd phase out use of this).
+ (WebCore::Loader::didReceivedResponse): most of the ReceivedResponse
+ logic.
+ * loader/loader.h:
+ * loader/mac/FrameLoaderMac.mm:
+ (WebCore::FrameLoader::loadResourceSynchronously): Return results
+ as ResourceResponse.
+ * loader/mac/IconLoaderMac.mm: remove receivedResponse.
+ * loader/mac/LoaderFunctionsMac.mm:
+ (WebCore::ServeSynchronousRequest): take ResourceResponse as
+ argument.
+ * platform/network/ResourceHandle.cpp:
+ * platform/network/ResourceHandle.h: Remove calls for
+ broken out response pieces.
+ * platform/network/ResourceHandleClient.h:
+ (WebCore::ResourceHandleClient::didReceiveResponse): New
+ delegate method.
+ * platform/network/ResourceHandleInternal.h:
+ (WebCore::ResourceHandleInternal::ResourceHandleInternal): Remove
+ storage of response bits, we're not gonna return them
+ seprately any more.
+ * platform/network/ResourceResponse.h: Added.
+ (WebCore::ResourceResponse::ResourceResponse): Freshly
+ implemented. Same for below.
+ (WebCore::ResourceResponse::url):
+ (WebCore::ResourceResponse::mimeType):
+ (WebCore::ResourceResponse::expectedContentLength):
+ (WebCore::ResourceResponse::textEncodingName):
+ (WebCore::ResourceResponse::suggestedFilename):
+ (WebCore::ResourceResponse::httpStatusCode):
+ (WebCore::ResourceResponse::setHTTPStatusCode):
+ (WebCore::ResourceResponse::httpHeaderField):
+ (WebCore::ResourceResponse::httpHeaderFields):
+ (WebCore::ResourceResponse::isMultipart):
+ (WebCore::ResourceResponse::setExpirationDate):
+ (WebCore::ResourceResponse::expirationDate):
+ * platform/network/cf/ResourceHandleCFNet.cpp:
+ (WebCore::didReceiveResponse): Send didReceiveResponse
+ client method.
+ * platform/network/cf/ResourceResponseCFNet.h: Added.
+ * platform/network/cf/ResourceResponseCFNet.mm: Added.
+ (getResourceResponse): Helper function to get a ResourceResponse
+ from CFURLResponseRef.
+ * platform/network/mac/ResourceHandleMac.mm:
+ (WebCore::ResourceHandleInternal::~ResourceHandleInternal):
+ Don't bother cleaning up fields we no longer have.
+ (WebCore::ResourceHandle::receivedResponse): Send
+ didReceiveResponse client method.
+ * platform/network/mac/ResourceResponseMac.h: Added.
+ * platform/network/mac/ResourceResponseMac.mm: Added.
+ (getResourceResponse): Helper function to get a ResourceResponse
+ from an NSURLResponse*.
+ * rendering/HitTestResult.cpp:
+ * xml/XSLTProcessor.cpp:
+ (WebCore::docLoaderFunc): Prepare for use of ResourceResponse.
+ * xml/xmlhttprequest.cpp:
+ (WebCore::XMLHttpRequest::getResponseText): Store http response
+ info in the form of a ResourceResponse, change all methods to
+ account for this.
+ (WebCore::XMLHttpRequest::getResponseXML):
+ (WebCore::XMLHttpRequest::XMLHttpRequest):
+ (WebCore::XMLHttpRequest::open):
+ (WebCore::XMLHttpRequest::send):
+ (WebCore::XMLHttpRequest::getAllResponseHeaders):
+ (WebCore::XMLHttpRequest::getResponseHeader):
+ (WebCore::XMLHttpRequest::getStatus):
+ (WebCore::XMLHttpRequest::getStatusText):
+ (WebCore::XMLHttpRequest::processSyncLoadResults):
+ (WebCore::XMLHttpRequest::didFinishLoading):
+ (WebCore::XMLHttpRequest::didReceiveResponse):
+ (WebCore::XMLHttpRequest::didReceiveData):
+ * xml/xmlhttprequest.h:
+
2006-10-29 Darin Adler <darin@apple.com>
- fix build
6582A16309999D6D00BEEB6D /* SystemTimeMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6582A15509999D6D00BEEB6D /* SystemTimeMac.cpp */; };
6582A17809999EA000BEEB6D /* DeprecatedStringMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 6582A17709999EA000BEEB6D /* DeprecatedStringMac.mm */; };
658436860AE01B7400E53753 /* FrameLoadRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 658436850AE01B7400E53753 /* FrameLoadRequest.h */; };
+ 658821660AF4CDF700F01D1F /* ResourceResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 658821650AF4CDF700F01D1F /* ResourceResponse.h */; };
+ 6588216B0AF4CE1200F01D1F /* ResourceResponseMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 658821680AF4CE1200F01D1F /* ResourceResponseMac.h */; };
+ 6588216C0AF4CE1200F01D1F /* ResourceResponseMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 658821690AF4CE1200F01D1F /* ResourceResponseMac.mm */; };
65901A4409FC6039005BD752 /* WebCoreStringTruncator.h in Headers */ = {isa = PBXBuildFile; fileRef = 65901A4209FC6039005BD752 /* WebCoreStringTruncator.h */; settings = {ATTRIBUTES = (Private, ); }; };
65901A4509FC6039005BD752 /* WebCoreStringTruncator.mm in Sources */ = {isa = PBXBuildFile; fileRef = 65901A4309FC6039005BD752 /* WebCoreStringTruncator.mm */; };
6593923709AE4346002C531F /* KURL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6593923509AE4346002C531F /* KURL.cpp */; };
6582A15509999D6D00BEEB6D /* SystemTimeMac.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = SystemTimeMac.cpp; sourceTree = "<group>"; };
6582A17709999EA000BEEB6D /* DeprecatedStringMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = DeprecatedStringMac.mm; sourceTree = "<group>"; };
658436850AE01B7400E53753 /* FrameLoadRequest.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = FrameLoadRequest.h; sourceTree = "<group>"; };
+ 658821650AF4CDF700F01D1F /* ResourceResponse.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = ResourceResponse.h; sourceTree = "<group>"; };
+ 658821680AF4CE1200F01D1F /* ResourceResponseMac.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = ResourceResponseMac.h; sourceTree = "<group>"; };
+ 658821690AF4CE1200F01D1F /* ResourceResponseMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = ResourceResponseMac.mm; sourceTree = "<group>"; };
65901A4209FC6039005BD752 /* WebCoreStringTruncator.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = WebCoreStringTruncator.h; sourceTree = "<group>"; };
65901A4309FC6039005BD752 /* WebCoreStringTruncator.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCoreStringTruncator.mm; sourceTree = "<group>"; };
6593923509AE4346002C531F /* KURL.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = KURL.cpp; sourceTree = "<group>"; };
isa = PBXGroup;
children = (
656B84E70AEA1DAE00A095B4 /* mac */,
- 6522BCDE09C9DAA800C9BA7A /* ResourceRequest.h */,
655A81BD0AEF67E6000975F0 /* HTTPHeaderMap.h */,
656B85370AEA1F9A00A095B4 /* ResourceHandle.h */,
656B84DC0AEA1D3100A095B4 /* ResourceHandle.cpp */,
656B84DE0AEA1D3100A095B4 /* ResourceHandleClient.h */,
656B84DF0AEA1D3100A095B4 /* ResourceHandleInternal.h */,
+ 6522BCDE09C9DAA800C9BA7A /* ResourceRequest.h */,
+ 658821650AF4CDF700F01D1F /* ResourceResponse.h */,
);
path = network;
sourceTree = "<group>";
isa = PBXGroup;
children = (
656B84EA0AEA1DDA00A095B4 /* ResourceHandleMac.mm */,
+ 658821680AF4CE1200F01D1F /* ResourceResponseMac.h */,
+ 658821690AF4CE1200F01D1F /* ResourceResponseMac.mm */,
);
path = mac;
sourceTree = "<group>";
655A81BE0AEF67E6000975F0 /* HTTPHeaderMap.h in Headers */,
930500200AF025D300FFF491 /* ClipboardAccessPolicy.h in Headers */,
9307F1D80AF2D59000DBA31A /* HitTestResult.h in Headers */,
+ 658821660AF4CDF700F01D1F /* ResourceResponse.h in Headers */,
+ 6588216B0AF4CE1200F01D1F /* ResourceResponseMac.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
853CA9F00AEEC657002372DC /* RenderPath.cpp in Sources */,
654F68880AF1B7C50065BDD6 /* CachedResourceMac.mm in Sources */,
9307F1D70AF2D59000DBA31A /* HitTestResult.cpp in Sources */,
+ 6588216C0AF4CE1200F01D1F /* ResourceResponseMac.mm in Sources */,
932E16090AF578340025F408 /* FrameLoader.cpp in Sources */,
93E227E00AF589AD00D48324 /* DocumentLoader.cpp in Sources */,
93E227E10AF589AD00D48324 /* MainResourceLoader.cpp in Sources */,
- (void)addMessageToConsole:(NSDictionary *)message;
- (void)runOpenPanelForFileButtonWithResultListener:(id <WebCoreOpenPanelResultListener>)resultListener;
-- (time_t)expiresTimeForResponse:(NSURLResponse *)response;
-
- (void)activateWindow;
- (void)deactivateWindow;
#include "LoaderFunctions.h"
#include "ProcessingInstruction.h"
#include "ResourceHandle.h"
+#include "ResourceResponse.h"
#include <libxml/parser.h>
#include <libxml/parserInternals.h>
#include <wtf/Platform.h>
KURL kurl(uri);
ResourceRequest request(kurl);
- KURL finalURL;
- DeprecatedString headers;
- Vector<char> data = ServeSynchronousRequest(cache()->loader(), globalDocLoader, request, finalURL, headers);
+ ResourceResponse response;
+ Vector<char> data = ServeSynchronousRequest(cache()->loader(), globalDocLoader, request, response);
return new OffsetBuffer(data);
}
class KURL;
class MainResourceLoader;
class ResourceRequest;
+ class ResourceResponse;
class String;
class SubresourceLoader;
class ResourceLoader;
bool canLoad(NSURL *, const String& referrer, bool& hideReferrer);
#endif
- void loadResourceSynchronously(const ResourceRequest&,
- KURL& finalURL, NSDictionary *& responseHeaders, int& statusCode, Vector<char>& data);
+ void loadResourceSynchronously(const ResourceRequest& request, Vector<char>& data, ResourceResponse& r);
// Also not cool.
void stopLoadingPlugIns();
class Request;
class ResourceRequest;
-Vector<char> ServeSynchronousRequest(Loader*, DocLoader*, const ResourceRequest&, KURL& finalURL, DeprecatedString& headers);
+Vector<char> ServeSynchronousRequest(Loader*, DocLoader*, const ResourceRequest&, ResourceResponse&);
void CheckCacheObjectStatus(DocLoader*, CachedResource*);
bool CheckIfReloading(DocLoader*);
DeprecatedString ResponseURL(PlatformResponse);
DeprecatedString ResponseMIMEType(PlatformResponse);
bool ResponseIsMultipart(PlatformResponse);
-time_t CacheObjectExpiresTime(DocLoader*, PlatformResponse);
NSString* HeaderStringFromDictionary(NSDictionary* headers, int statusCode);
}
#include "loader/icon/IconDatabase.h"
#include "Logging.h"
#include "page/Frame.h"
+#include "ResourceResponse.h"
#if PLATFORM(MAC)
#include "FrameMac.h"
m_data.clear();
}
+void IconLoader::didReceiveResponse(ResourceHandle* resourceLoader, const ResourceResponse& response)
+{
+ ASSERT(resourceLoader);
+ m_httpStatusCode = response.httpStatusCode();
+}
+
void IconLoader::didReceiveData(ResourceHandle* resourceLoader, const char* data, int size)
{
ASSERT(resourceLoader == m_resourceLoader);
void startLoading();
void stopLoading();
-// ResourceHandleClient delegate methods
- virtual void receivedResponse(ResourceHandle*, PlatformResponse);
+ // ResourceHandleClient delegate methods
+ virtual void didReceiveResponse(ResourceHandle*, const ResourceResponse&);
virtual void didReceiveData(ResourceHandle*, const char*, int);
virtual void didFinishLoading(ResourceHandle*);
private:
#include "LoaderFunctions.h"
#include "Request.h"
#include "ResourceHandle.h"
+#include "ResourceResponse.h"
#include <wtf/Assertions.h>
#include <wtf/Vector.h>
servePendingRequests();
}
-void Loader::receivedResponse(ResourceHandle* job, PlatformResponse response)
+void Loader::receivedResponse(ResourceHandle* handle, PlatformResponse response)
{
- Request* req = m_requestsLoading.get(job);
+ Request* req = m_requestsLoading.get(handle);
ASSERT(req);
#if !PLATFORM(WIN)
// FIXME: the win32 platform does not have PlatformResponse yet.
ASSERT(response);
#endif
req->cachedResource()->setResponse(response);
- req->cachedResource()->setExpireDate(CacheObjectExpiresTime(req->docLoader(), response), false);
+}
+
+void Loader::didReceivedResponse(ResourceHandle* handle, const ResourceResponse& response)
+{
+ Request* req = m_requestsLoading.get(handle);
+ ASSERT(req);
+ req->cachedResource()->setExpireDate(response.expirationDate(), false);
- String encoding = job->responseEncoding();
+ String encoding = response.textEncodingName();
if (!encoding.isNull())
req->cachedResource()->setEncoding(encoding);
static_cast<CachedImage*>(req->cachedResource())->clear();
if (req->docLoader()->frame())
req->docLoader()->frame()->checkCompleted();
- } else if (ResponseIsMultipart(response)) {
+ } else if (response.isMultipart()) {
req->setIsMultipart(true);
if (!req->cachedResource()->isImage())
- job->cancel();
+ handle->cancel();
}
}
private:
virtual void receivedResponse(ResourceHandle*, PlatformResponse);
+ virtual void didReceivedResponse(ResourceHandle* handle, const ResourceResponse& response);
virtual void didReceiveData(ResourceHandle*, const char*, int);
virtual void receivedAllData(ResourceHandle*, PlatformData);
#import "LoaderNSURLRequestExtras.h"
#import "Page.h"
#import "Plugin.h"
+#import "ResourceResponse.h"
+#import "ResourceResponseMac.h"
#import "WebCoreFrameBridge.h"
#import "WebCoreIconDatabaseBridge.h"
#import "WebCorePageState.h"
[url release];
}
-void FrameLoader::loadResourceSynchronously(const ResourceRequest& request,
- KURL& finalURL, NSDictionary *& responseHeaders, int& statusCode, Vector<char>& data)
+void FrameLoader::loadResourceSynchronously(const ResourceRequest& request, Vector<char>& data, ResourceResponse& r)
{
#if 0
NSDictionary *headerDict = nil;
[initialRequest release];
- if (error == nil) {
- finalURL = [response URL];
- if ([response isKindOfClass:[NSHTTPURLResponse class]]) {
- NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
- responseHeaders = [httpResponse allHeaderFields];
- statusCode = [httpResponse statusCode];
- } else {
- responseHeaders = [NSDictionary dictionary];
- statusCode = 200;
- }
- } else {
- finalURL = URL;
- responseHeaders = [NSDictionary dictionary];
+ if (error == nil)
+ getResourceResponse(r, response);
+ else {
+ r = ResourceResponse(URL, String(), 0, String(), String());
if ([error domain] == NSURLErrorDomain)
- statusCode = [error code];
+ r.setHTTPStatusCode([error code]);
else
- statusCode = 404;
+ r.setHTTPStatusCode(404);
}
sendRemainingDelegateMessages(identifier, response, [result length], error);
using namespace WebCore;
-void IconLoader::receivedResponse(ResourceHandle* resourceLoader, NSURLResponse* responsePtr)
-{
- ASSERT(resourceLoader);
- ASSERT(responsePtr);
-
- id response = responsePtr;
- if ([response isKindOfClass:[NSHTTPURLResponse class]])
- m_httpStatusCode = [response statusCode];
- else
- m_httpStatusCode = 0;
-}
-
void IconLoader::notifyIconChanged(const KURL& iconURL)
{
m_frame->loader()->notifyIconChanged(iconURL.getNSURL());
return headerString;
}
-Vector<char> ServeSynchronousRequest(Loader *loader, DocLoader *docLoader, const ResourceRequest& request, KURL &finalURL, DeprecatedString &responseHeaders)
+Vector<char> ServeSynchronousRequest(Loader *loader, DocLoader *docLoader, const ResourceRequest& request, ResourceResponse& response)
{
FrameMac *frame = static_cast<FrameMac *>(docLoader->frame());
BEGIN_BLOCK_OBJC_EXCEPTIONS;
- NSDictionary *responseHeaderDict = nil;
- int statusCode = 0;
Vector<char> result;
- frame->loader()->loadResourceSynchronously(request, finalURL, responseHeaderDict, statusCode, result);
-
- responseHeaders = DeprecatedString::fromNSString(HeaderStringFromDictionary(responseHeaderDict, statusCode));
+ frame->loader()->loadResourceSynchronously(request, result, response);
return result;
return false;
}
-time_t CacheObjectExpiresTime(DocLoader *docLoader, PlatformResponse response)
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
-
- FrameMac *frame = static_cast<FrameMac *>(docLoader->frame());
- if (frame) {
- WebCoreFrameBridge *bridge = frame->bridge();
- return [bridge expiresTimeForResponse:(NSURLResponse *)response];
- }
-
- END_BLOCK_OBJC_EXCEPTIONS;
-
- return 0;
-}
-
void CachedResource::setResponse(PlatformResponse response)
{
HardRetain(response);
d->status = e;
}
-String ResourceHandle::responseEncoding() const
-{
- retrieveResponseEncoding();
-
- return d->m_responseEncoding;
-}
-
-String ResourceHandle::responseHTTPHeadersAsString() const
-{
- assembleResponseHeaders();
- return d->responseHeaders;
-}
-
void ResourceHandle::kill()
{
if (d->m_loading){
String errorText() const;
bool isErrorPage() const;
- String responseEncoding() const;
-
- String responseHTTPHeadersAsString() const;
void kill();
#if PLATFORM(MAC)
private:
bool start(DocLoader*);
- void assembleResponseHeaders() const;
- void retrieveResponseEncoding() const;
-
ResourceHandleInternal* d;
};
class KURL;
class ResourceHandle;
+ class ResourceResponse;
class ResourceHandleClient {
public:
// void didReceiveAuthenticationChallenge(ResourceHandle*, const AuthenticationChallenge&) { }
// void didCancelAuthenticationChallenge(ResourceHandle*, const AuthenticationChallenge&) { }
- // void didReceiveResponse(ResourceHandle*, const ResourceResponse&) { }
+ virtual void didReceiveResponse(ResourceHandle*, const ResourceResponse&) { }
virtual void didReceiveData(ResourceHandle*, const char*, int) { }
virtual void didFinishLoading(ResourceHandle*) { }
// void didFailWithError(ResourceError*) { }
: m_client(c)
, m_request(request)
, status(0)
- , assembledResponseHeaders(true)
- , m_retrievedResponseEncoding(true)
, m_loading(false)
, m_cancelled(false)
#if USE(CFNETWORK)
, m_connection(0)
-#elif PLATFORM(MAC)
- , loader(nil)
- , response(nil)
#endif
#if USE(WININET)
, m_fileHandle(INVALID_HANDLE_VALUE)
ResourceRequest m_request;
int status;
- String m_responseEncoding;
- DeprecatedString responseHeaders;
- bool assembledResponseHeaders;
- bool m_retrievedResponseEncoding;
-
bool m_loading;
bool m_cancelled;
#if USE(CFNETWORK)
CFURLConnectionRef m_connection;
#elif PLATFORM(MAC)
- WebCoreResourceLoaderImp* loader;
RefPtr<WebCore::SubresourceLoader> m_subresourceLoader;
- NSURLResponse* response;
#endif
#if USE(WININET)
HANDLE m_fileHandle;
--- /dev/null
+// -*- mode: c++; c-basic-offset: 4 -*-
+/*
+ * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef ResourceResponse_h_
+#define ResourceResponse_h_
+
+#include "HTTPHeaderMap.h"
+#include "KURL.h"
+
+namespace WebCore {
+
+class ResourceResponse {
+public:
+
+ ResourceResponse() : m_expectedContentLength(0), m_httpStatusCode(0) {}
+
+ ResourceResponse(const KURL& url, const String& mimeType, long long expectedLength, const String& textEncodingName, const String& filename)
+ : m_url(url)
+ , m_mimeType(mimeType)
+ , m_expectedContentLength(expectedLength)
+ , m_textEncodingName(textEncodingName)
+ , m_suggestedFilename(filename)
+ , m_httpStatusCode(0)
+ {
+ }
+
+ const KURL& url() const { return m_url; }
+ const String& mimeType() const { return m_mimeType; }
+ long long expectedContentLength() const { return m_expectedContentLength; }
+ const String& textEncodingName() const { return m_textEncodingName; }
+
+ // FIXME should compute this on the fly
+ const String& suggestedFilename() const { return m_suggestedFilename; }
+
+ int httpStatusCode() const { return m_httpStatusCode; }
+ void setHTTPStatusCode(int statusCode) { m_httpStatusCode = statusCode; }
+ const String& httpStatusText() const { return m_httpStatusText; }
+ void setHTTPStatusText(const String& statusText) { m_httpStatusText = statusText; }
+ String httpHeaderField(const String& name) const { return m_httpHeaderFields.get(name); }
+ const HTTPHeaderMap& httpHeaderFields() const { return m_httpHeaderFields; }
+ HTTPHeaderMap& httpHeaderFields() { return m_httpHeaderFields; }
+
+ // possibly add calculated expiration info
+ // lastModifiedDate (date)
+
+ bool isMultipart() const { return m_mimeType == "multipart/x-mixed-replace"; }
+
+ void setExpirationDate(time_t expirationDate) { m_expirationDate = expirationDate; }
+ time_t expirationDate() const { return m_expirationDate; }
+
+ private:
+ KURL m_url;
+ String m_mimeType;
+ long long m_expectedContentLength;
+ String m_textEncodingName;
+ String m_suggestedFilename;
+ int m_httpStatusCode;
+ String m_httpStatusText;
+ HTTPHeaderMap m_httpHeaderFields;
+ time_t m_expirationDate;
+};
+
+} // namespace WebCore
+
+#endif // ResourceResponse_h_
#if USE(CFNETWORK)
-#include "ResourceHandle.h"
-#include "ResourceHandleInternal.h"
#include "DocLoader.h"
#include "Frame.h"
+#include "ResourceHandle.h"
+#include "ResourceHandleInternal.h"
+#include "ResourceResponse.h"
+#include "ResourceResponseCFNet.h"
#include <WTF/HashMap.h>
return request;
}
-void didReceiveResponse(CFURLConnectionRef conn, CFURLResponseRef response, const void* clientInfo)
+void didReceiveResponse(CFURLConnectionRef conn, CFURLResponseRef cfResponse, const void* clientInfo)
{
- ResourceHandle* job = (ResourceHandle*)clientInfo;
+ ResourceHandle* handle = (ResourceHandle*)clientInfo;
#if defined(LOG_RESOURCELOADER_EVENTS)
- CFStringRef str = CFStringCreateWithFormat(0, 0, CFSTR("didReceiveResponse(conn=%p, job = %p)\n"), conn, job);
+ CFStringRef str = CFStringCreateWithFormat(0, 0, CFSTR("didReceiveResponse(conn=%p, job = %p)\n"), conn, handle);
CFShow(str);
CFRelease(str);
#endif
- job->client()->receivedResponse(job, response);
+ if (ResourceHandleClient* client = handle->client()) {
+ client->receivedResponse(handle, cfResponse);
+ ResourceResponse response;
+ getResourceResponse(response, cfResponse);
+ client->didReceiveResponse(handle, response);
+ }
}
void didReceiveData(CFURLConnectionRef conn, CFDataRef data, CFIndex originalLength, const void* clientInfo)
--- /dev/null
+// -*- mode: c++; c-basic-offset: 4 -*-
+/*
+ * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "ResourceResponseCFNet.h"
+
+#include "ResourceResponse.h"
+#include <CFNetwork/CFURLResponsePriv.h>
+
+// We would like a better value for a maximum time_t,
+// but there is no way to do that in C with any certainty.
+// INT_MAX should work well enough for our purposes.
+#define MAX_TIME_T ((time_t)INT_MAX)
+
+namespace WebCore {
+
+ void getResourceResponse(ResourceResponse& response, CFURLResponseRef cfResponse)
+ {
+ // FIXME: we may need to do MIME type sniffing here (unless that is done
+ // in CFURLResponseGetMIMEType
+
+ response = ResourceResponse(CFURLResponseGetURL(cfResponse), CFURLResponseGetMIMEType(cfResponse), CFURLResponseGetExpectedContentLength(cfResponse), CFURLResponseGetTextEncodingName(cfResponse), /* suggestedFilename */ "");
+
+ CFAbsoluteTime expiration = CFURLResponseGetExpirationTime(cfResponse);
+ response.setExpirationDate(expiration > MAX_TIME_T ? MAX_TIME_T : (time_t)expiration);
+
+ CFHTTPMessageRef httpResponse = CFURLResponseGetHTTPResponse(cfResponse);
+ if (httpResponse) {
+ response.setHTTPStatusCode(CFHTTPMessageGetResponseStatusCode(httpResponse));
+
+ CFStringRef statusLine = CFHTTPMessageCopyResponseStatusLine(httpResponse);
+ String statusText(statusLine);
+ CFRelease(statusLine);
+ int spacePos = statusText.find(" ");
+ if (spacePos != -1)
+ statusText = statusText.substring(spacePos + 1);
+ response.setHTTPStatusText(statusText);
+
+ CFDictionaryRef headers = CFHTTPMessageCopyAllHeaderFields(httpResponse);
+ CFIndex headerCount = CFDictionaryGetCount(headers);
+ Vector<const void*, 128> keys(headerCount);
+ Vector<const void*, 128> values(headerCount);
+ CFDictionaryGetKeysAndValues(headers, keys.data(), values.data());
+ for (int i = 0; i < headerCount; ++i)
+ response.httpHeaderFields().set((CFStringRef)keys[i], (CFStringRef)values[i]);
+ }
+ }
+
+}
--- /dev/null
+// -*- mode: c++; c-basic-offset: 4 -*-
+/*
+ * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef ResourceResponseCFNet_h_
+#define ResourceResponseCFNet_h_
+
+typedef struct _CFURLResponse* CFURLResponseRef;
+
+namespace WebCore {
+
+ class ResourceResponse;
+
+ void getResourceResponse(ResourceResponse& response, CFURLResponseRef cfResponse);
+
+}
+
+#endif // ResourceResponseCFNet_h_
#import "KURL.h"
#import "LoaderFunctions.h"
#import "Logging.h"
+#import "ResourceResponse.h"
+#import "ResourceResponseMac.h"
#import "WebCoreFrameBridge.h"
#import "SubresourceLoader.h"
ResourceHandleInternal::~ResourceHandleInternal()
{
- HardRelease(response);
- HardRelease(loader);
}
ResourceHandle::~ResourceHandle()
return false;
}
-void ResourceHandle::assembleResponseHeaders() const
+void ResourceHandle::receivedResponse(NSURLResponse* nsResponse)
{
- if (!d->assembledResponseHeaders) {
- if ([d->response isKindOfClass:[NSHTTPURLResponse class]]) {
- NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)d->response;
- NSDictionary *headers = [httpResponse allHeaderFields];
- d->responseHeaders = DeprecatedString::fromNSString(HeaderStringFromDictionary(headers, [httpResponse statusCode]));
- }
- d->assembledResponseHeaders = true;
- }
-}
+ ASSERT(nsResponse);
-void ResourceHandle::retrieveResponseEncoding() const
-{
- if (!d->m_retrievedResponseEncoding) {
- NSString *textEncodingName = [d->response textEncodingName];
- if (textEncodingName)
- d->m_responseEncoding = textEncodingName;
- d->m_retrievedResponseEncoding = true;
+ if (client()) {
+ client()->receivedResponse(this, nsResponse);
+ ResourceResponse response;
+ getResourceResponse(response, nsResponse);
+ client()->didReceiveResponse(this, response);
}
}
-void ResourceHandle::receivedResponse(NSURLResponse* response)
-{
- ASSERT(response);
-
- d->assembledResponseHeaders = false;
- d->m_retrievedResponseEncoding = false;
- d->response = response;
- HardRetain(d->response);
- if (client())
- client()->receivedResponse(this, response);
-}
-
void ResourceHandle::cancel()
{
d->m_subresourceLoader->cancel();
--- /dev/null
+// -*- mode: c++; c-basic-offset: 4 -*-
+/*
+ * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef ResourceResponseMac_h_
+#define ResourceResponseMac_h_
+
+@class NSURLResponse;
+
+namespace WebCore {
+
+ class ResourceResponse;
+
+ void getResourceResponse(ResourceResponse& response, NSURLResponse *nsResponse);
+
+}
+
+#endif // ResourceResponseMac_h_
--- /dev/null
+// -*- mode: c++; c-basic-offset: 4 -*-
+/*
+ * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "ResourceResponseMac.h"
+
+#import "ResourceResponse.h"
+
+#import <Foundation/Foundation.h>
+
+@interface NSURLResponse (FoundationSecretsWebCoreKnowsAbout)
+- (NSTimeInterval)_calculatedExpiration;
+@end
+
+// We would like a better value for a maximum time_t,
+// but there is no way to do that in C with any certainty.
+// INT_MAX should work well enough for our purposes.
+#define MAX_TIME_T ((time_t)INT_MAX)
+
+namespace WebCore {
+
+ void getResourceResponse(ResourceResponse& response, NSURLResponse *nsResponse)
+ {
+ response = ResourceResponse([nsResponse URL], [nsResponse MIMEType], [nsResponse expectedContentLength], [nsResponse textEncodingName], [nsResponse suggestedFilename]);
+
+ NSTimeInterval expiration = [nsResponse _calculatedExpiration];
+ expiration += kCFAbsoluteTimeIntervalSince1970;
+ response.setExpirationDate(expiration > MAX_TIME_T ? MAX_TIME_T : (time_t)expiration);
+
+
+ if ([nsResponse isKindOfClass:[NSHTTPURLResponse class]]) {
+ NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)nsResponse;
+
+ response.setHTTPStatusCode([httpResponse statusCode]);
+
+ // FIXME: it would be nice to have a way to get the real
+ // status text eventually
+ response.setHTTPStatusText("OK");
+
+ NSDictionary *headers = [httpResponse allHeaderFields];
+ NSEnumerator *e = [headers keyEnumerator];
+ NSString *name;
+ while ((name = [e nextObject]))
+ response.httpHeaderFields().set(name, [headers objectForKey:name]);
+ }
+ }
+
+}
#include "Frame.h"
#include "FrameTree.h"
#include "HTMLElement.h"
-#include "PlatformScrollbar.h"
+#include "PlatformScrollBar.h"
#include "RenderObject.h"
namespace WebCore {
#include "HTMLTokenizer.h"
#include "LoaderFunctions.h"
#include "ResourceHandle.h"
+#include "ResourceResponse.h"
#include "Text.h"
#include "loader.h"
#include "markup.h"
KURL url((const char*)base, (const char*)uri);
xmlFree(base);
ResourceRequest request(url);
- KURL finalURL;
- DeprecatedString headers;
+ ResourceResponse response;
xmlGenericErrorFunc oldErrorFunc = xmlGenericError;
void *oldErrorContext = xmlGenericErrorContext;
- Vector<char> data = ServeSynchronousRequest(cache()->loader(), globalDocLoader, request, finalURL, headers);
+ Vector<char> data = ServeSynchronousRequest(cache()->loader(), globalDocLoader, request, response);
xmlSetGenericErrorFunc(0, parseErrorFunc);
// We don't specify an encoding here. Neither Gecko nor WinIE respects
String XMLHttpRequest::getResponseText() const
{
- return m_response;
+ return m_responseText;
}
Document* XMLHttpRequest::getResponseXML() const
if (responseIsXML()) {
m_responseXML = m_doc->implementation()->createDocument();
m_responseXML->open();
- m_responseXML->write(m_response);
+ m_responseXML->write(m_responseText);
m_responseXML->finishParsing();
m_responseXML->close();
}
, m_async(true)
, m_loader(0)
, m_state(Uninitialized)
- , m_response("", 0)
+ , m_responseText("", 0)
, m_createdDocument(false)
, m_aborted(false)
{
// clear stuff from possible previous load
m_requestHeaders.clear();
- m_responseHeaders = String();
- m_response = "";
+ m_response = ResourceResponse();
+ m_responseText = "";
m_createdDocument = false;
m_responseXML = 0;
if (!m_async) {
Vector<char> data;
- KURL finalURL;
- DeprecatedString headers;
+ ResourceResponse response;
{
// avoid deadlock in case the loader wants to use JS on a background thread
KJS::JSLock::DropAllLocks dropLocks;
- data = ServeSynchronousRequest(cache()->loader(), m_doc->docLoader(), request, finalURL, headers);
+ data = ServeSynchronousRequest(cache()->loader(), m_doc->docLoader(), request, response);
}
m_loader = 0;
- processSyncLoadResults(data, finalURL, headers);
+ processSyncLoadResults(data, response);
return;
}
String XMLHttpRequest::getAllResponseHeaders() const
{
- if (m_responseHeaders.isEmpty())
- return String();
+ Vector<UChar> stringBuilder;
+ String separator(": ");
- int endOfLine = m_responseHeaders.find("\n");
- if (endOfLine == -1)
- return String();
+ HTTPHeaderMap::const_iterator end = m_response.httpHeaderFields().end();
+ for (HTTPHeaderMap::const_iterator it = m_response.httpHeaderFields().begin(); it!= end; ++it) {
+ stringBuilder.append(it->first.characters(), it->first.length());
+ stringBuilder.append(separator.characters(), separator.length());
+ stringBuilder.append(it->second.characters(), it->second.length());
+ stringBuilder.append((UChar)'\n');
+ }
- return m_responseHeaders.substring(endOfLine + 1) + "\n";
+ return String::adopt(stringBuilder);
}
String XMLHttpRequest::getResponseHeader(const String& name) const
{
- return getSpecificHeader(m_responseHeaders.deprecatedString(), name.deprecatedString());
-}
-
-DeprecatedString XMLHttpRequest::getSpecificHeader(const DeprecatedString& headers, const DeprecatedString& name)
-{
- if (headers.isEmpty())
- return DeprecatedString();
-
- RegularExpression headerLinePattern(name + ":", false);
-
- int matchLength;
- int headerLinePos = headerLinePattern.match(headers, 0, &matchLength);
- while (headerLinePos != -1) {
- if (headerLinePos == 0 || headers[headerLinePos-1] == '\n')
- break;
- headerLinePos = headerLinePattern.match(headers, headerLinePos + 1, &matchLength);
- }
- if (headerLinePos == -1)
- return DeprecatedString();
-
- int endOfLine = headers.find("\n", headerLinePos + matchLength);
- return headers.mid(headerLinePos + matchLength, endOfLine - (headerLinePos + matchLength)).stripWhiteSpace();
+ return m_response.httpHeaderField(name);
}
bool XMLHttpRequest::responseIsXML() const
if (m_state == Uninitialized)
return 0;
- if (m_responseHeaders.isEmpty()) {
+ if (m_response.httpStatusCode() == 0) {
if (m_state != Receiving && m_state != Loaded)
// status MUST be available in these states, but we don't get any headers from non-HTTP requests
ec = INVALID_STATE_ERR;
- return 0;
}
-
- int endOfLine = m_responseHeaders.find("\n");
- String firstLine = endOfLine == -1 ? m_responseHeaders : m_responseHeaders.substring(0, endOfLine);
- int codeStart = firstLine.find(" ");
- int codeEnd = firstLine.find(" ", codeStart + 1);
- ASSERT(codeStart != -1);
- ASSERT(codeEnd != -1);
-
- String number = firstLine.substring(codeStart + 1, codeEnd - (codeStart + 1));
- bool ok = false;
- int code = number.toInt(&ok);
- ASSERT(ok);
- return code;
+ return m_response.httpStatusCode();
}
String XMLHttpRequest::getStatusText(ExceptionCode& ec) const
if (m_state == Uninitialized)
return "";
- if (m_responseHeaders.isEmpty()) {
+ if (m_response.httpStatusCode() == 0) {
if (m_state != Receiving && m_state != Loaded)
// statusText MUST be available in these states, but we don't get any headers from non-HTTP requests
ec = INVALID_STATE_ERR;
return String();
}
-
- int endOfLine = m_responseHeaders.find("\n");
- String firstLine = endOfLine == -1 ? m_responseHeaders : m_responseHeaders.substring(0, endOfLine);
- int codeStart = firstLine.find(" ");
- int codeEnd = firstLine.find(" ", codeStart + 1);
- ASSERT(codeStart != -1);
- ASSERT(codeEnd != -1);
-
- return firstLine.substring(codeEnd + 1, endOfLine - (codeEnd + 1)).stripWhiteSpace();
+
+ // FIXME: should try to preserve status text in response
+ return "OK";
}
-void XMLHttpRequest::processSyncLoadResults(const Vector<char>& data, const KURL& finalURL, const DeprecatedString& headers)
+void XMLHttpRequest::processSyncLoadResults(const Vector<char>& data, const ResourceResponse& response)
{
- if (!urlMatchesDocumentDomain(finalURL)) {
+ if (!urlMatchesDocumentDomain(response.url())) {
abort();
return;
}
- m_responseHeaders = headers;
+ didReceiveResponse(0, response);
changeState(Sent);
if (m_aborted)
return;
{
ASSERT(loader == m_loader);
- if (m_responseHeaders.isEmpty() && m_loader)
- m_responseHeaders = m_loader->responseHTTPHeadersAsString();
-
if (m_state < Sent)
changeState(Sent);
if (m_decoder)
- m_response += m_decoder->flush();
+ m_responseText += m_decoder->flush();
bool hadLoader = m_loader;
m_loader = 0;
abort();
}
-void XMLHttpRequest::didReceiveData(ResourceHandle*, const char* data, int len)
+void XMLHttpRequest::didReceiveResponse(ResourceHandle*, const ResourceResponse& response)
{
- if (m_responseHeaders.isEmpty() && m_loader)
- m_responseHeaders = m_loader->responseHTTPHeadersAsString();
+ m_response = response;
+ m_encoding = getCharset(m_mimeTypeOverride);
+ if (m_encoding.isEmpty())
+ m_encoding = response.textEncodingName();
+
+}
+void XMLHttpRequest::didReceiveData(ResourceHandle*, const char* data, int len)
+{
if (m_state < Sent)
changeState(Sent);
if (!m_decoder) {
- m_encoding = getCharset(m_mimeTypeOverride);
- if (m_encoding.isEmpty())
- m_encoding = getCharset(getResponseHeader("Content-Type"));
- if (m_encoding.isEmpty() && m_loader)
- m_encoding = m_loader->responseEncoding();
-
if (!m_encoding.isEmpty())
m_decoder = new TextResourceDecoder("text/plain", m_encoding);
else if (responseIsXML())
String decoded = m_decoder->decode(data, len);
- m_response += decoded;
+ m_responseText += decoded;
if (!m_aborted) {
if (m_state != Receiving)
#include <wtf/Vector.h>
#include "KURL.h"
#include "ResourceHandleClient.h"
+#include "ResourceResponse.h"
#include "PlatformString.h"
#include "HTTPHeaderMap.h"
#include "StringHash.h"
bool urlMatchesDocumentDomain(const KURL&) const;
virtual void receivedRedirect(ResourceHandle*, const KURL&);
+ virtual void didReceiveResponse(ResourceHandle*, const ResourceResponse&);
virtual void didReceiveData(ResourceHandle*, const char* data, int size);
virtual void didFinishLoading(ResourceHandle*);
- void processSyncLoadResults(const Vector<char>& data, const KURL& finalURL, const DeprecatedString& headers);
+ void processSyncLoadResults(const Vector<char>& data, const ResourceResponse&);
bool responseIsXML() const;
String getRequestHeader(const String& name) const;
- static DeprecatedString getSpecificHeader(const DeprecatedString& headers, const DeprecatedString& name);
void changeState(XMLHttpRequestState newState);
void callReadyStateChangeListener();
KURL m_url;
DeprecatedString m_method;
- bool m_async;
HTTPHeaderMap m_requestHeaders;
+ String m_mimeTypeOverride;
+ bool m_async;
RefPtr<ResourceHandle> m_loader;
-
XMLHttpRequestState m_state;
- RefPtr<TextResourceDecoder> m_decoder;
+ ResourceResponse m_response;
String m_encoding;
- String m_responseHeaders;
- String m_mimeTypeOverride;
- String m_response;
+ RefPtr<TextResourceDecoder> m_decoder;
+ String m_responseText;
mutable bool m_createdDocument;
mutable RefPtr<Document> m_responseXML;
+2006-10-29 Maciej Stachowiak <mjs@apple.com>
+
+ Reviewed by Anders.
+
+ - added ResourceResponse class and didReceiveResponse delegate call
+
+ * WebCoreSupport/WebFrameBridge.mm: Removed no longer needed
+ expiresTimeForResponse: method.
+
2006-10-29 Darin Adler <darin@apple.com>
- update for the WebCore rename
- (NSView *)_findLastViewInKeyViewLoop;
@end
-@interface NSURLResponse (FoundationSecretsWebBridgeKnowsAbout)
-- (NSTimeInterval)_calculatedExpiration;
-@end
-
@interface NSView (JavaPluginSecrets)
- (jobject)pollForAppletInWindow:(NSWindow *)window;
@end
[[wv _UIDelegateForwarder] webView:wv setStatusText:status];
}
-// We would like a better value for a maximum time_t,
-// but there is no way to do that in C with any certainty.
-// INT_MAX should work well enough for our purposes.
-#define MAX_TIME_T ((time_t)INT_MAX)
-
-- (time_t)expiresTimeForResponse:(NSURLResponse *)response
-{
- // This check can be removed when the new Foundation method
- // has been around long enough for everyone to have it.
- ASSERT([response respondsToSelector:@selector(_calculatedExpiration)]);
-
- NSTimeInterval expiration = [response _calculatedExpiration];
- expiration += kCFAbsoluteTimeIntervalSince1970;
-
- return expiration > MAX_TIME_T ? MAX_TIME_T : (time_t)expiration;
-}
-
- (void)close
{
[super close];