2 * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
16 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
19 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
23 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 #include <wtf/Vector.h>
32 #include <kio/netaccess.h>
41 #include "ResourceHandle.h"
42 #include "ResourceRequest.h"
43 #include "DocLoader.h"
44 #include "CachedResource.h"
45 #include "DeprecatedString.h"
49 Vector<char> ServeSynchronousRequest(Loader*, DocLoader *docLoader, const ResourceRequest& request, ResourceResponse&)
51 // FIXME: Handle last paremeter: "responseHeaders"
52 FrameQt* frame = QtFrame(docLoader->frame());
55 return Vector<char>();
57 // FIXME: We shouldn't use temporary files for sync jobs!
60 if (!KIO::NetAccess::download(KUrl(request.url().url()), tempFile, 0))
61 return Vector<char>();
63 KURL url = request.url();
64 if (!url.isLocalFile())
65 return Vector<char>();
66 tempFile = url.path();
70 if (!file.open(QIODevice::ReadOnly)) {
72 KIO::NetAccess::removeTempFile(tempFile);
74 return Vector<char>();
77 ASSERT(!file.atEnd());
79 QByteArray content = file.readAll();
81 KIO::NetAccess::removeTempFile(tempFile);
84 Vector<char> resultBuffer;
85 resultBuffer.append(content.data(), content.size());
90 int NumberOfPendingOrLoadingRequests(DocLoader* docLoader)
92 return cache()->loader()->numRequests(docLoader);
95 bool CheckIfReloading(WebCore::DocLoader* docLoader)
97 // FIXME: Needs a real implementation!
101 void CheckCacheObjectStatus(DocLoader* docLoader, CachedResource* cachedResource)
103 // Return from the function for objects that we didn't load from the cache.
107 switch (cachedResource->status()) {
108 case CachedResource::Cached:
110 case CachedResource::NotCached:
111 case CachedResource::Unknown:
112 case CachedResource::New:
113 case CachedResource::Pending:
117 // FIXME: Doesn't work at the moment! ASSERT(cachedResource->response());
119 // FIXME: Notify the caller that we "loaded".
122 bool IsResponseURLEqualToURL(PlatformResponse response, const String& url)
127 return response->url == QString(url);
130 DeprecatedString ResponseURL(PlatformResponse response)
133 return DeprecatedString();
135 return response->url;
138 DeprecatedString ResponseMIMEType(PlatformResponse)
140 // FIXME: Store the response mime type in QtPlatformResponse!
141 return DeprecatedString();
144 bool ResponseIsMultipart(PlatformResponse response)
146 return ResponseMIMEType(response) == "multipart/x-mixed-replace";
149 time_t CacheObjectExpiresTime(DocLoader*, PlatformResponse)
151 // FIXME: Implement me!
155 void CachedResource::setPlatformResponse(PlatformResponse response)
157 m_platformResponse = response;
160 void CachedResource::setAllData(PlatformData allData)
165 } // namespace WebCore