diff options
Diffstat (limited to 'src/3rdparty/webkit/WebCore/platform/network')
31 files changed, 1197 insertions, 105 deletions
diff --git a/src/3rdparty/webkit/WebCore/platform/network/Credential.cpp b/src/3rdparty/webkit/WebCore/platform/network/Credential.cpp index 474395935..f90574319 100644 --- a/src/3rdparty/webkit/WebCore/platform/network/Credential.cpp +++ b/src/3rdparty/webkit/WebCore/platform/network/Credential.cpp @@ -32,6 +32,7 @@ namespace WebCore { Credential::Credential() : m_user("") , m_password("") + , m_persistence(CredentialPersistenceNone) { } @@ -43,6 +44,11 @@ Credential::Credential(const String& user, const String& password, CredentialPer , m_persistence(persistence) { } + +bool Credential::isEmpty() const +{ + return m_user.isEmpty() && m_password.isEmpty(); +} const String& Credential::user() const { diff --git a/src/3rdparty/webkit/WebCore/platform/network/Credential.h b/src/3rdparty/webkit/WebCore/platform/network/Credential.h index 4d8049045..0471fbca7 100644 --- a/src/3rdparty/webkit/WebCore/platform/network/Credential.h +++ b/src/3rdparty/webkit/WebCore/platform/network/Credential.h @@ -41,6 +41,8 @@ public: Credential(); Credential(const String& user, const String& password, CredentialPersistence); + bool isEmpty() const; + const String& user() const; const String& password() const; bool hasPassword() const; diff --git a/src/3rdparty/webkit/WebCore/platform/network/CredentialStorage.cpp b/src/3rdparty/webkit/WebCore/platform/network/CredentialStorage.cpp new file mode 100644 index 000000000..ec7837264 --- /dev/null +++ b/src/3rdparty/webkit/WebCore/platform/network/CredentialStorage.cpp @@ -0,0 +1,155 @@ +/* + * Copyright (C) 2009 Apple 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 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 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 "CredentialStorage.h" + +#include "CString.h" +#include "Credential.h" +#include "KURL.h" +#include "ProtectionSpaceHash.h" +#include "StringHash.h" + +#include <wtf/StdLibExtras.h> + +namespace WebCore { + +typedef HashMap<ProtectionSpace, Credential> ProtectionSpaceToCredentialMap; +static ProtectionSpaceToCredentialMap& protectionSpaceToCredentialMap() +{ + DEFINE_STATIC_LOCAL(ProtectionSpaceToCredentialMap, map, ()); + return map; +} + +static HashSet<String>& originsWithCredentials() +{ + DEFINE_STATIC_LOCAL(HashSet<String>, set, ()); + return set; +} + +typedef HashMap<String, ProtectionSpace> PathToDefaultProtectionSpaceMap; +static PathToDefaultProtectionSpaceMap& pathToDefaultProtectionSpaceMap() +{ + DEFINE_STATIC_LOCAL(PathToDefaultProtectionSpaceMap, map, ()); + return map; +} + +static String originStringFromURL(const KURL& url) +{ + if (url.port()) + return url.protocol() + "://" + url.host() + String::format(":%i/", url.port()); + + return url.protocol() + "://" + url.host() + "/"; +} + +static String protectionSpaceMapKeyFromURL(const KURL& url) +{ + ASSERT(url.isValid()); + + // Remove the last path component that is not a directory to determine the subtree for which credentials will apply. + // We keep a leading slash, but remove a trailing one. + String directoryURL = url.string().substring(0, url.pathEnd()); + unsigned directoryURLPathStart = url.pathStart(); + ASSERT(directoryURL[directoryURLPathStart] == '/'); + if (directoryURL.length() > directoryURLPathStart + 1) { + int index = directoryURL.reverseFind('/'); + ASSERT(index > 0); + directoryURL = directoryURL.substring(0, (static_cast<unsigned>(index) != directoryURLPathStart) ? index : directoryURLPathStart + 1); + } + ASSERT(directoryURL.length() == directoryURLPathStart + 1 || directoryURL[directoryURL.length() - 1] != '/'); + + return directoryURL; +} + +void CredentialStorage::set(const Credential& credential, const ProtectionSpace& protectionSpace, const KURL& url) +{ + ASSERT(url.protocolInHTTPFamily()); + ASSERT(url.isValid()); + + protectionSpaceToCredentialMap().set(protectionSpace, credential); + originsWithCredentials().add(originStringFromURL(url)); + + ProtectionSpaceAuthenticationScheme scheme = protectionSpace.authenticationScheme(); + if (scheme == ProtectionSpaceAuthenticationSchemeHTTPBasic || scheme == ProtectionSpaceAuthenticationSchemeDefault) { + // The map can contain both a path and its subpath - while redundant, this makes lookups faster. + pathToDefaultProtectionSpaceMap().set(protectionSpaceMapKeyFromURL(url), protectionSpace); + } +} + +Credential CredentialStorage::get(const ProtectionSpace& protectionSpace) +{ + return protectionSpaceToCredentialMap().get(protectionSpace); +} + +static PathToDefaultProtectionSpaceMap::iterator findDefaultProtectionSpaceForURL(const KURL& url) +{ + ASSERT(url.protocolInHTTPFamily()); + ASSERT(url.isValid()); + + PathToDefaultProtectionSpaceMap& map = pathToDefaultProtectionSpaceMap(); + + // Don't spend time iterating the path for origins that don't have any credentials. + if (!originsWithCredentials().contains(originStringFromURL(url))) + return map.end(); + + String directoryURL = protectionSpaceMapKeyFromURL(url); + unsigned directoryURLPathStart = url.pathStart(); + while (true) { + PathToDefaultProtectionSpaceMap::iterator iter = map.find(directoryURL); + if (iter != map.end()) + return iter; + + if (directoryURL.length() == directoryURLPathStart + 1) // path is "/" already, cannot shorten it any more + return map.end(); + + int index = directoryURL.reverseFind('/', -2); + ASSERT(index > 0); + directoryURL = directoryURL.substring(0, (static_cast<unsigned>(index) == directoryURLPathStart) ? index + 1 : index); + ASSERT(directoryURL.length() > directoryURLPathStart); + ASSERT(directoryURL.length() == directoryURLPathStart + 1 || directoryURL[directoryURL.length() - 1] != '/'); + } +} + +bool CredentialStorage::set(const Credential& credential, const KURL& url) +{ + ASSERT(url.protocolInHTTPFamily()); + ASSERT(url.isValid()); + PathToDefaultProtectionSpaceMap::iterator iter = findDefaultProtectionSpaceForURL(url); + if (iter == pathToDefaultProtectionSpaceMap().end()) + return false; + ASSERT(originsWithCredentials().contains(originStringFromURL(url))); + protectionSpaceToCredentialMap().set(iter->second, credential); + return true; +} + +Credential CredentialStorage::get(const KURL& url) +{ + PathToDefaultProtectionSpaceMap::iterator iter = findDefaultProtectionSpaceForURL(url); + if (iter == pathToDefaultProtectionSpaceMap().end()) + return Credential(); + return protectionSpaceToCredentialMap().get(iter->second); +} + +} // namespace WebCore diff --git a/src/3rdparty/webkit/WebCore/platform/network/CredentialStorage.h b/src/3rdparty/webkit/WebCore/platform/network/CredentialStorage.h new file mode 100644 index 000000000..5086f69f6 --- /dev/null +++ b/src/3rdparty/webkit/WebCore/platform/network/CredentialStorage.h @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2009 Apple 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 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 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 SessionCredentialStorage_h +#define SessionCredentialStorage_h + +namespace WebCore { + +class Credential; +class KURL; +class ProtectionSpace; + +class CredentialStorage { +public: + static void set(const Credential&, const ProtectionSpace&, const KURL&); + static Credential get(const ProtectionSpace&); + + // These methods work for authentication schemes that support sending credentials without waiting for a request. E.g., for HTTP Basic authentication scheme + // a client should assume that all paths at or deeper than the depth of a known protected resource share are within the same protection space. + static bool set(const Credential&, const KURL&); // Returns true if the URL corresponds to a known protection space, so credentials could be updated. + static Credential get(const KURL&); +}; + +} // namespace WebCore + +#endif // SessionCredentialStorage_h diff --git a/src/3rdparty/webkit/WebCore/platform/network/FormDataBuilder.cpp b/src/3rdparty/webkit/WebCore/platform/network/FormDataBuilder.cpp index 27bdee319..04c75278c 100644 --- a/src/3rdparty/webkit/WebCore/platform/network/FormDataBuilder.cpp +++ b/src/3rdparty/webkit/WebCore/platform/network/FormDataBuilder.cpp @@ -108,6 +108,34 @@ static inline void append(Vector<char>& buffer, const CString& string) buffer.append(string.data(), string.length()); } +static void appendQuotedString(Vector<char>& buffer, const CString& string) +{ + // Append a string as a quoted value, escaping quotes and line breaks. + // FIXME: Is it correct to use percent escaping here? Other browsers do not encode these characters yet, + // so we should test popular servers to find out if there is an encoding form they can handle. + unsigned length = string.length(); + for (unsigned i = 0; i < length; ++i) { + unsigned char c = string.data()[i]; + + switch (c) { + case 0x0a: + append(buffer, "%0A"); + break; + case 0x0d: + append(buffer, "%0D"); + break; + case '"': + append(buffer, "%22"); + break; + case '%': + append(buffer, "%25"); + break; + default: + append(buffer, c); + } + } +} + Vector<char> FormDataBuilder::generateUniqueBoundaryString() { Vector<char> boundary; @@ -161,8 +189,10 @@ void FormDataBuilder::beginMultiPartHeader(Vector<char>& buffer, const CString& { addBoundaryToMultiPartHeader(buffer, boundary); + // FIXME: This loses data irreversibly if the input name includes characters you can't encode + // in the website's character set. append(buffer, "Content-Disposition: form-data; name=\""); - append(buffer, name); + appendQuotedString(buffer, name); append(buffer, '"'); } @@ -179,12 +209,10 @@ void FormDataBuilder::addBoundaryToMultiPartHeader(Vector<char>& buffer, const C void FormDataBuilder::addFilenameToMultiPartHeader(Vector<char>& buffer, const TextEncoding& encoding, const String& filename) { - // FIXME: This won't work if the filename includes a " mark, - // or control characters like CR or LF. This also does strange - // things if the filename includes characters you can't encode + // FIXME: This loses data irreversibly if the filename includes characters you can't encode // in the website's character set. append(buffer, "; filename=\""); - append(buffer, encoding.encode(filename.characters(), filename.length(), QuestionMarksForUnencodables)); + appendQuotedString(buffer, encoding.encode(filename.characters(), filename.length(), QuestionMarksForUnencodables)); append(buffer, '"'); } diff --git a/src/3rdparty/webkit/WebCore/platform/network/HTTPHeaderMap.cpp b/src/3rdparty/webkit/WebCore/platform/network/HTTPHeaderMap.cpp index ff470a023..07c66e815 100644 --- a/src/3rdparty/webkit/WebCore/platform/network/HTTPHeaderMap.cpp +++ b/src/3rdparty/webkit/WebCore/platform/network/HTTPHeaderMap.cpp @@ -45,7 +45,7 @@ auto_ptr<CrossThreadHTTPHeaderMapData> HTTPHeaderMap::copyData() const HTTPHeaderMap::const_iterator end_it = end(); for (HTTPHeaderMap::const_iterator it = begin(); it != end_it; ++it) { - data->append(make_pair(it->first.string().copy(), it->second.copy())); + data->append(make_pair(it->first.string().crossThreadString(), it->second.crossThreadString())); } return data; } diff --git a/src/3rdparty/webkit/WebCore/platform/network/HTTPParsers.cpp b/src/3rdparty/webkit/WebCore/platform/network/HTTPParsers.cpp index e57401ec0..9202660df 100644 --- a/src/3rdparty/webkit/WebCore/platform/network/HTTPParsers.cpp +++ b/src/3rdparty/webkit/WebCore/platform/network/HTTPParsers.cpp @@ -100,6 +100,13 @@ bool parseHTTPRefresh(const String& refresh, bool fromHttpEquivMeta, double& del if (refresh[urlEndPos] == quotationMark) break; } + + // https://bugs.webkit.org/show_bug.cgi?id=27868 + // Sometimes there is no closing quote for the end of the URL even though there was an opening quote. + // If we looped over the entire alleged URL string back to the opening quote, just go ahead and use everything + // after the opening quote instead. + if (urlEndPos == urlStartPos) + urlEndPos = len; } url = refresh.substring(urlStartPos, urlEndPos - urlStartPos).stripWhiteSpace(); diff --git a/src/3rdparty/webkit/WebCore/platform/network/ProtectionSpace.cpp b/src/3rdparty/webkit/WebCore/platform/network/ProtectionSpace.cpp index bd73558e5..d04bcbe81 100644 --- a/src/3rdparty/webkit/WebCore/platform/network/ProtectionSpace.cpp +++ b/src/3rdparty/webkit/WebCore/platform/network/ProtectionSpace.cpp @@ -37,7 +37,11 @@ namespace WebCore { // combined with the semantics of the String(NSString*) constructor ProtectionSpace::ProtectionSpace() : m_host("") + , m_port(0) + , m_serverType(ProtectionSpaceServerHTTP) , m_realm("") + , m_authenticationScheme(ProtectionSpaceAuthenticationSchemeDefault) + , m_isHashTableDeletedValue(false) { } @@ -49,6 +53,7 @@ ProtectionSpace::ProtectionSpace(const String& host, int port, ProtectionSpaceSe , m_serverType(serverType) , m_realm(realm.length() ? realm : "") , m_authenticationScheme(authenticationScheme) + , m_isHashTableDeletedValue(false) { } diff --git a/src/3rdparty/webkit/WebCore/platform/network/ProtectionSpace.h b/src/3rdparty/webkit/WebCore/platform/network/ProtectionSpace.h index 9a73cff63..126b49995 100644 --- a/src/3rdparty/webkit/WebCore/platform/network/ProtectionSpace.h +++ b/src/3rdparty/webkit/WebCore/platform/network/ProtectionSpace.h @@ -54,6 +54,10 @@ class ProtectionSpace { public: ProtectionSpace(); ProtectionSpace(const String& host, int port, ProtectionSpaceServerType, const String& realm, ProtectionSpaceAuthenticationScheme); + + // Hash table deleted values, which are only constructed and never copied or destroyed. + ProtectionSpace(WTF::HashTableDeletedValueType) : m_isHashTableDeletedValue(true) { } + bool isHashTableDeletedValue() const { return m_isHashTableDeletedValue; } const String& host() const; int port() const; @@ -70,10 +74,12 @@ private: ProtectionSpaceServerType m_serverType; String m_realm; ProtectionSpaceAuthenticationScheme m_authenticationScheme; + bool m_isHashTableDeletedValue; }; bool operator==(const ProtectionSpace& a, const ProtectionSpace& b); inline bool operator!=(const ProtectionSpace& a, const ProtectionSpace& b) { return !(a == b); } -} -#endif +} // namespace WebCore + +#endif // ProtectionSpace_h diff --git a/src/3rdparty/webkit/WebCore/platform/network/ProtectionSpaceHash.h b/src/3rdparty/webkit/WebCore/platform/network/ProtectionSpaceHash.h new file mode 100644 index 000000000..6f68b5b8c --- /dev/null +++ b/src/3rdparty/webkit/WebCore/platform/network/ProtectionSpaceHash.h @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2009 Apple 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 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 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 ProtectionSpaceHash_h +#define ProtectionSpaceHash_h + +#include "ProtectionSpace.h" + +namespace WebCore { + +struct ProtectionSpaceHash { + static unsigned hash(const ProtectionSpace& protectionSpace) + { + unsigned hashCodes[5] = { + protectionSpace.host().impl() ? protectionSpace.host().impl()->hash() : 0, + protectionSpace.port(), + protectionSpace.serverType(), + protectionSpace.realm().impl() ? protectionSpace.realm().impl()->hash() : 0, + protectionSpace.authenticationScheme() + }; + + return StringImpl::computeHash(reinterpret_cast<UChar*>(hashCodes), sizeof(hashCodes) / sizeof(UChar)); + } + + static bool equal(const ProtectionSpace& a, const ProtectionSpace& b) { return a == b; } + static const bool safeToCompareToEmptyOrDeleted = false; +}; + +} // namespace WebCore + +namespace WTF { + + // WebCore::ProtectionSpaceHash is the default hash for ProtectionSpace + template<> struct HashTraits<WebCore::ProtectionSpace> : GenericHashTraits<WebCore::ProtectionSpace> { + static const bool emptyValueIsZero = true; + static void constructDeletedValue(WebCore::ProtectionSpace& slot) { new (&slot) WebCore::ProtectionSpace(HashTableDeletedValue); } + static bool isDeletedValue(const WebCore::ProtectionSpace& slot) { return slot.isHashTableDeletedValue(); } + }; + + template<typename T> struct DefaultHash; + template<> struct DefaultHash<WebCore::ProtectionSpace> { + typedef WebCore::ProtectionSpaceHash Hash; + }; + +} // namespace WTF + + +#endif // ProtectionSpaceHash_h diff --git a/src/3rdparty/webkit/WebCore/platform/network/ResourceErrorBase.cpp b/src/3rdparty/webkit/WebCore/platform/network/ResourceErrorBase.cpp index 370650f6a..97435bad5 100644 --- a/src/3rdparty/webkit/WebCore/platform/network/ResourceErrorBase.cpp +++ b/src/3rdparty/webkit/WebCore/platform/network/ResourceErrorBase.cpp @@ -34,10 +34,10 @@ ResourceError ResourceErrorBase::copy() const lazyInit(); ResourceError errorCopy; - errorCopy.m_domain = m_domain.copy(); + errorCopy.m_domain = m_domain.crossThreadString(); errorCopy.m_errorCode = m_errorCode; - errorCopy.m_failingURL = m_failingURL.copy(); - errorCopy.m_localizedDescription = m_localizedDescription.copy(); + errorCopy.m_failingURL = m_failingURL.crossThreadString(); + errorCopy.m_localizedDescription = m_localizedDescription.crossThreadString(); errorCopy.m_isNull = m_isNull; errorCopy.m_isCancellation = m_isCancellation; return errorCopy; diff --git a/src/3rdparty/webkit/WebCore/platform/network/ResourceHandle.h b/src/3rdparty/webkit/WebCore/platform/network/ResourceHandle.h index 4cb3561b8..a7dc9566b 100644 --- a/src/3rdparty/webkit/WebCore/platform/network/ResourceHandle.h +++ b/src/3rdparty/webkit/WebCore/platform/network/ResourceHandle.h @@ -105,7 +105,7 @@ public: static PassRefPtr<ResourceHandle> create(const ResourceRequest&, ResourceHandleClient*, Frame*, bool defersLoading, bool shouldContentSniff, bool mightDownloadFromHandle = false); static void loadResourceSynchronously(const ResourceRequest&, StoredCredentials, ResourceError&, ResourceResponse&, Vector<char>& data, Frame* frame); - static bool willLoadFromCache(ResourceRequest&); + static bool willLoadFromCache(ResourceRequest&, Frame*); #if PLATFORM(MAC) static bool didSendBodyDataDelegateExists(); #endif diff --git a/src/3rdparty/webkit/WebCore/platform/network/ResourceHandleInternal.h b/src/3rdparty/webkit/WebCore/platform/network/ResourceHandleInternal.h index 091a26b0d..1733deaa0 100644 --- a/src/3rdparty/webkit/WebCore/platform/network/ResourceHandleInternal.h +++ b/src/3rdparty/webkit/WebCore/platform/network/ResourceHandleInternal.h @@ -150,6 +150,8 @@ namespace WebCore { String m_user; String m_pass; + Credential m_initialCredential; + int status; bool m_defersLoading; diff --git a/src/3rdparty/webkit/WebCore/platform/network/ResourceRequestBase.cpp b/src/3rdparty/webkit/WebCore/platform/network/ResourceRequestBase.cpp index bfa3dc623..e0707d960 100644 --- a/src/3rdparty/webkit/WebCore/platform/network/ResourceRequestBase.cpp +++ b/src/3rdparty/webkit/WebCore/platform/network/ResourceRequestBase.cpp @@ -62,7 +62,7 @@ auto_ptr<ResourceRequest> ResourceRequestBase::adopt(auto_ptr<CrossThreadResourc request->setResponseContentDispositionEncodingFallbackArray(encoding1, encoding2, encoding3); } request->setHTTPBody(data->m_httpBody); - request->setAllowHTTPCookies(data->m_allowHTTPCookies); + request->setAllowCookies(data->m_allowCookies); return request; } @@ -73,17 +73,17 @@ auto_ptr<CrossThreadResourceRequestData> ResourceRequestBase::copyData() const data->m_cachePolicy = cachePolicy(); data->m_timeoutInterval = timeoutInterval(); data->m_firstPartyForCookies = firstPartyForCookies().copy(); - data->m_httpMethod = httpMethod().copy(); + data->m_httpMethod = httpMethod().crossThreadString(); data->m_httpHeaders.adopt(httpHeaderFields().copyData()); data->m_responseContentDispositionEncodingFallbackArray.reserveInitialCapacity(m_responseContentDispositionEncodingFallbackArray.size()); size_t encodingArraySize = m_responseContentDispositionEncodingFallbackArray.size(); for (size_t index = 0; index < encodingArraySize; ++index) { - data->m_responseContentDispositionEncodingFallbackArray.append(m_responseContentDispositionEncodingFallbackArray[index].copy()); + data->m_responseContentDispositionEncodingFallbackArray.append(m_responseContentDispositionEncodingFallbackArray[index].crossThreadString()); } if (m_httpBody) data->m_httpBody = m_httpBody->deepCopy(); - data->m_allowHTTPCookies = m_allowHTTPCookies; + data->m_allowCookies = m_allowCookies; return data; } @@ -218,6 +218,26 @@ void ResourceRequestBase::setHTTPHeaderField(const AtomicString& name, const Str m_platformRequestUpdated = false; } +void ResourceRequestBase::clearHTTPReferrer() +{ + updateResourceRequest(); + + m_httpHeaderFields.remove("Referer"); + + if (url().protocolInHTTPFamily()) + m_platformRequestUpdated = false; +} + +void ResourceRequestBase::clearHTTPOrigin() +{ + updateResourceRequest(); + + m_httpHeaderFields.remove("Origin"); + + if (url().protocolInHTTPFamily()) + m_platformRequestUpdated = false; +} + void ResourceRequestBase::setResponseContentDispositionEncodingFallbackArray(const String& encoding1, const String& encoding2, const String& encoding3) { updateResourceRequest(); @@ -251,18 +271,18 @@ void ResourceRequestBase::setHTTPBody(PassRefPtr<FormData> httpBody) m_platformRequestUpdated = false; } -bool ResourceRequestBase::allowHTTPCookies() const +bool ResourceRequestBase::allowCookies() const { updateResourceRequest(); - return m_allowHTTPCookies; + return m_allowCookies; } -void ResourceRequestBase::setAllowHTTPCookies(bool allowHTTPCookies) +void ResourceRequestBase::setAllowCookies(bool allowCookies) { updateResourceRequest(); - m_allowHTTPCookies = allowHTTPCookies; + m_allowCookies = allowCookies; if (url().protocolInHTTPFamily()) m_platformRequestUpdated = false; @@ -274,6 +294,9 @@ void ResourceRequestBase::addHTTPHeaderField(const AtomicString& name, const Str pair<HTTPHeaderMap::iterator, bool> result = m_httpHeaderFields.add(name, value); if (!result.second) result.first->second += "," + value; + + if (url().protocolInHTTPFamily()) + m_platformRequestUpdated = false; } void ResourceRequestBase::addHTTPHeaderFields(const HTTPHeaderMap& headerFields) @@ -300,7 +323,7 @@ bool equalIgnoringHeaderFields(const ResourceRequestBase& a, const ResourceReque if (a.httpMethod() != b.httpMethod()) return false; - if (a.allowHTTPCookies() != b.allowHTTPCookies()) + if (a.allowCookies() != b.allowCookies()) return false; FormData* formDataA = a.httpBody(); @@ -355,7 +378,7 @@ void ResourceRequestBase::updateResourceRequest() const m_resourceRequestUpdated = true; } -#if !PLATFORM(MAC) && !USE(CFNETWORK) +#if !PLATFORM(MAC) && !USE(CFNETWORK) && !USE(SOUP) && !PLATFORM(CHROMIUM) unsigned initializeMaximumHTTPConnectionCountPerHost() { // This is used by the loader to control the number of issued parallel load requests. diff --git a/src/3rdparty/webkit/WebCore/platform/network/ResourceRequestBase.h b/src/3rdparty/webkit/WebCore/platform/network/ResourceRequestBase.h index 2d87d6e36..84a7bd0b7 100644 --- a/src/3rdparty/webkit/WebCore/platform/network/ResourceRequestBase.h +++ b/src/3rdparty/webkit/WebCore/platform/network/ResourceRequestBase.h @@ -88,11 +88,11 @@ namespace WebCore { String httpReferrer() const { return httpHeaderField("Referer"); } void setHTTPReferrer(const String& httpReferrer) { setHTTPHeaderField("Referer", httpReferrer); } - void clearHTTPReferrer() { m_httpHeaderFields.remove("Referer"); } + void clearHTTPReferrer(); String httpOrigin() const { return httpHeaderField("Origin"); } void setHTTPOrigin(const String& httpOrigin) { setHTTPHeaderField("Origin", httpOrigin); } - void clearHTTPOrigin() { m_httpHeaderFields.remove("Origin"); } + void clearHTTPOrigin(); String httpUserAgent() const { return httpHeaderField("User-Agent"); } void setHTTPUserAgent(const String& httpUserAgent) { setHTTPHeaderField("User-Agent", httpUserAgent); } @@ -105,8 +105,8 @@ namespace WebCore { FormData* httpBody() const; void setHTTPBody(PassRefPtr<FormData> httpBody); - bool allowHTTPCookies() const; - void setAllowHTTPCookies(bool allowHTTPCookies); + bool allowCookies() const; + void setAllowCookies(bool allowCookies); bool isConditional() const; @@ -129,7 +129,7 @@ namespace WebCore { , m_cachePolicy(policy) , m_timeoutInterval(unspecifiedTimeoutInterval) , m_httpMethod("GET") - , m_allowHTTPCookies(true) + , m_allowCookies(true) , m_resourceRequestUpdated(true) , m_platformRequestUpdated(false) , m_reportUploadProgress(false) @@ -148,7 +148,7 @@ namespace WebCore { HTTPHeaderMap m_httpHeaderFields; Vector<String> m_responseContentDispositionEncodingFallbackArray; RefPtr<FormData> m_httpBody; - bool m_allowHTTPCookies; + bool m_allowCookies; mutable bool m_resourceRequestUpdated; mutable bool m_platformRequestUpdated; bool m_reportUploadProgress; @@ -173,7 +173,7 @@ namespace WebCore { OwnPtr<CrossThreadHTTPHeaderMapData> m_httpHeaders; Vector<String> m_responseContentDispositionEncodingFallbackArray; RefPtr<FormData> m_httpBody; - bool m_allowHTTPCookies; + bool m_allowCookies; }; unsigned initializeMaximumHTTPConnectionCountPerHost(); diff --git a/src/3rdparty/webkit/WebCore/platform/network/ResourceResponseBase.cpp b/src/3rdparty/webkit/WebCore/platform/network/ResourceResponseBase.cpp index 7f8a4e2f5..fd442252f 100644 --- a/src/3rdparty/webkit/WebCore/platform/network/ResourceResponseBase.cpp +++ b/src/3rdparty/webkit/WebCore/platform/network/ResourceResponseBase.cpp @@ -108,12 +108,12 @@ auto_ptr<CrossThreadResourceResponseData> ResourceResponseBase::copyData() const { auto_ptr<CrossThreadResourceResponseData> data(new CrossThreadResourceResponseData()); data->m_url = url().copy(); - data->m_mimeType = mimeType().copy(); + data->m_mimeType = mimeType().crossThreadString(); data->m_expectedContentLength = expectedContentLength(); - data->m_textEncodingName = textEncodingName().copy(); - data->m_suggestedFilename = suggestedFilename().copy(); + data->m_textEncodingName = textEncodingName().crossThreadString(); + data->m_suggestedFilename = suggestedFilename().crossThreadString(); data->m_httpStatusCode = httpStatusCode(); - data->m_httpStatusText = httpStatusText().copy(); + data->m_httpStatusText = httpStatusText().crossThreadString(); data->m_httpHeaders.adopt(httpHeaderFields().copyData()); data->m_lastModifiedDate = lastModifiedDate(); return data; diff --git a/src/3rdparty/webkit/WebCore/platform/network/SocketStreamErrorBase.cpp b/src/3rdparty/webkit/WebCore/platform/network/SocketStreamErrorBase.cpp new file mode 100644 index 000000000..72fb44ce9 --- /dev/null +++ b/src/3rdparty/webkit/WebCore/platform/network/SocketStreamErrorBase.cpp @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 THE COPYRIGHT + * OWNER 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 "SocketStreamError.h" + +namespace WebCore { + +SocketStreamError SocketStreamErrorBase::copy() const +{ + SocketStreamError errorCopy; + errorCopy.m_errorCode = m_errorCode; + return errorCopy; +} + +bool SocketStreamErrorBase::compare(const SocketStreamError& a, const SocketStreamError& b) +{ + return a.errorCode() == b.errorCode(); +} + +} // namespace WebCore diff --git a/src/3rdparty/webkit/WebCore/platform/network/SocketStreamErrorBase.h b/src/3rdparty/webkit/WebCore/platform/network/SocketStreamErrorBase.h new file mode 100644 index 000000000..b7ca35bdc --- /dev/null +++ b/src/3rdparty/webkit/WebCore/platform/network/SocketStreamErrorBase.h @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2009 Apple Inc. All rights reserved. + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 THE COPYRIGHT + * OWNER 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 SocketStreamErrorBase_h +#define SocketStreamErrorBase_h + +namespace WebCore { + + class SocketStreamError; + + class SocketStreamErrorBase { + public: + // Makes a deep copy. Useful for when you need to use a SocketStreamError on another thread. + SocketStreamError copy() const; + + bool isNull() const { return m_isNull; } + + int errorCode() const { return m_errorCode; } + + static bool compare(const SocketStreamError&, const SocketStreamError&); + + protected: + SocketStreamErrorBase() + : m_errorCode(0) + , m_isNull(true) + { + } + + explicit SocketStreamErrorBase(int errorCode) + : m_errorCode(errorCode) + , m_isNull(false) + { + } + + int m_errorCode; + bool m_isNull; + }; + + inline bool operator==(const SocketStreamError& a, const SocketStreamError& b) { return SocketStreamErrorBase::compare(a, b); } + inline bool operator!=(const SocketStreamError& a, const SocketStreamError& b) { return !(a == b); } + +} // namespace WebCore + +#endif // SocketStreamErrorBase_h diff --git a/src/3rdparty/webkit/WebCore/platform/network/SocketStreamHandleBase.cpp b/src/3rdparty/webkit/WebCore/platform/network/SocketStreamHandleBase.cpp new file mode 100644 index 000000000..875c2485d --- /dev/null +++ b/src/3rdparty/webkit/WebCore/platform/network/SocketStreamHandleBase.cpp @@ -0,0 +1,106 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 THE COPYRIGHT + * OWNER 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 "SocketStreamHandleBase.h" + +#include "SocketStreamHandleClient.h" + +namespace WebCore { + +const unsigned int bufferSize = 100 * 1024 * 1024; + +SocketStreamHandleBase::SocketStreamHandleBase(const KURL& url, SocketStreamHandleClient* client) + : m_url(url) + , m_client(client) + , m_state(Connecting) +{ +} + +SocketStreamHandleBase::SocketStreamState SocketStreamHandleBase::state() const +{ + return m_state; +} + +bool SocketStreamHandleBase::send(const char* data, int length) +{ + if (m_state == Connecting) + return false; + if (!m_buffer.isEmpty()) { + if (m_buffer.size() + length > bufferSize) { + // FIXME: report error to indicate that buffer has no more space. + return false; + } + m_buffer.append(data, length); + return true; + } + int bytesWritten = 0; + if (m_state == Open) + bytesWritten = platformSend(data, length); + if (bytesWritten <= 0) + return false; + if (m_buffer.size() + length - bytesWritten > bufferSize) { + // FIXME: report error to indicate that buffer has no more space. + return false; + } + if (bytesWritten < length) + m_buffer.append(data + bytesWritten, length - bytesWritten); + return true; +} + +void SocketStreamHandleBase::close() +{ + platformClose(); + m_state = Closed; +} + +void SocketStreamHandleBase::setClient(SocketStreamHandleClient* client) +{ + ASSERT(!client || (!m_client && m_state == Connecting)); + m_client = client; +} + +bool SocketStreamHandleBase::sendPendingData() +{ + if (m_state != Open) + return false; + if (m_buffer.isEmpty()) + return false; + int bytesWritten = platformSend(m_buffer.data(), m_buffer.size()); + if (bytesWritten <= 0) + return false; + Vector<char> remainingData; + ASSERT(m_buffer.size() - bytesWritten <= bufferSize); + remainingData.append(m_buffer.data() + bytesWritten, m_buffer.size() - bytesWritten); + m_buffer.swap(remainingData); + return true; +} + +} // namespace WebCore diff --git a/src/3rdparty/webkit/WebCore/platform/network/SocketStreamHandleBase.h b/src/3rdparty/webkit/WebCore/platform/network/SocketStreamHandleBase.h new file mode 100644 index 000000000..fc011dda1 --- /dev/null +++ b/src/3rdparty/webkit/WebCore/platform/network/SocketStreamHandleBase.h @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2009 Apple Inc. All rights reserved. + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 THE COPYRIGHT + * OWNER 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 SocketStreamHandleBase_h +#define SocketStreamHandleBase_h + +#include "KURL.h" + +#include <wtf/Vector.h> + +namespace WebCore { + + class SocketStreamHandle; + class SocketStreamHandleClient; + + class SocketStreamHandleBase { + public: + enum SocketStreamState { Connecting, Open, Closed }; + virtual ~SocketStreamHandleBase() { } + SocketStreamState state() const; + + bool send(const char* data, int length); + void close(); + int bufferedAmount() const { return m_buffer.size(); } + + SocketStreamHandleClient* client() const { return m_client; } + void setClient(SocketStreamHandleClient*); + + protected: + SocketStreamHandleBase(const KURL&, SocketStreamHandleClient*); + + bool sendPendingData(); + virtual int platformSend(const char* data, int length) = 0; + virtual void platformClose() = 0; + + KURL m_url; + SocketStreamHandleClient* m_client; + Vector<char> m_buffer; + SocketStreamState m_state; + }; + +} // namespace WebCore + +#endif // SocketStreamHandleBase_h diff --git a/src/3rdparty/webkit/WebCore/platform/network/SocketStreamHandleClient.h b/src/3rdparty/webkit/WebCore/platform/network/SocketStreamHandleClient.h new file mode 100644 index 000000000..04c744e96 --- /dev/null +++ b/src/3rdparty/webkit/WebCore/platform/network/SocketStreamHandleClient.h @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2009 Apple Inc. All rights reserved. + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 THE COPYRIGHT + * OWNER 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 SocketStreamHandleClient_h +#define SocketStreamHandleClient_h + +namespace WebCore { + + class AuthenticationChallenge; + class KURL; + class SocketStreamError; + class SocketStreamHandle; + + class SocketStreamHandleClient { + public: + virtual ~SocketStreamHandleClient() { } + + virtual void willOpenStream(SocketStreamHandle*, const KURL&) { } + virtual void willSendData(SocketStreamHandle*, const char* /*data*/, int /*length*/) { } + + virtual void didOpen(SocketStreamHandle*) { } + virtual void didClose(SocketStreamHandle*) { } + virtual void didReceiveData(SocketStreamHandle*, const char* /*data*/, int /*length*/) { } + + virtual void didFail(SocketStreamHandle*, const SocketStreamError&) { } + + virtual void didReceiveAuthenticationChallenge(SocketStreamHandle*, const AuthenticationChallenge&) { } + virtual void didCancelAuthenticationChallenge(SocketStreamHandle*, const AuthenticationChallenge&) { } + virtual void receivedCancellation(SocketStreamHandle*, const AuthenticationChallenge&) { } + }; + +} // namespace WebCore + +#endif // SocketStreamHandleClient_h diff --git a/src/3rdparty/webkit/WebCore/platform/network/qt/DnsPrefetchHelper.cpp b/src/3rdparty/webkit/WebCore/platform/network/qt/DnsPrefetchHelper.cpp new file mode 100644 index 000000000..e687976a1 --- /dev/null +++ b/src/3rdparty/webkit/WebCore/platform/network/qt/DnsPrefetchHelper.cpp @@ -0,0 +1,35 @@ +/* + Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "config.h" +#include "DnsPrefetchHelper.h" + +#include "CString.h" + +namespace WebCore { +// this is called on mouse over a href and on page loading +void prefetchDNS(const String& hostname) +{ + if (QWebSettings::globalSettings()->testAttribute(QWebSettings::DnsPrefetchEnabled)) { + static DnsPrefetchHelper dnsPrefetchHelper; + dnsPrefetchHelper.lookup(QString(hostname)); + } +} + +} diff --git a/src/3rdparty/webkit/WebCore/platform/network/qt/DnsPrefetchHelper.h b/src/3rdparty/webkit/WebCore/platform/network/qt/DnsPrefetchHelper.h new file mode 100644 index 000000000..0d98fcb1e --- /dev/null +++ b/src/3rdparty/webkit/WebCore/platform/network/qt/DnsPrefetchHelper.h @@ -0,0 +1,75 @@ +/* + Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ +#ifndef DNSPREFETCHHELPER_H +#define DNSPREFETCHHELPER_H + +#include <QObject> +#include <QCache> +#include <QHostInfo> +#include <QSet> +#include <QString> +#include <QTime> +#include "qwebsettings.h" + +namespace WebCore { + + class DnsPrefetchHelper : public QObject { + Q_OBJECT + public: + DnsPrefetchHelper() : QObject(), currentLookups(0) {}; + + public slots: + void lookup(QString hostname) + { + if (hostname.isEmpty()) + return; // this actually happens + if (currentLookups >= 10) + return; // do not launch more than 10 lookups at the same time + + QTime* entryTime = lookupCache.object(hostname); + if (entryTime && entryTime->elapsed() > 300*1000) { + // delete knowledge about lookup if it is already 300 seconds old + lookupCache.remove(hostname); + } else if (!entryTime) { + // not in cache yet, can look it up + QTime *tmpTime = new QTime(); + *tmpTime = QTime::currentTime(); + lookupCache.insert(hostname, tmpTime); + currentLookups++; + QHostInfo::lookupHost(hostname, this, SLOT(lookedUp(QHostInfo))); + } + } + + void lookedUp(const QHostInfo&) + { + // we do not cache the result, we throw it away. + // we currently rely on the OS to cache the results. If it does not do that + // then at least the ISP nameserver did it. + currentLookups--; + } + + protected: + QCache<QString, QTime> lookupCache; // 100 entries + int currentLookups; + }; + + +} + +#endif // DNSPREFETCHHELPER_H diff --git a/src/3rdparty/webkit/WebCore/platform/network/qt/QNetworkReplyHandler.cpp b/src/3rdparty/webkit/WebCore/platform/network/qt/QNetworkReplyHandler.cpp index 898e5f49c..1ac80f68f 100644 --- a/src/3rdparty/webkit/WebCore/platform/network/qt/QNetworkReplyHandler.cpp +++ b/src/3rdparty/webkit/WebCore/platform/network/qt/QNetworkReplyHandler.cpp @@ -112,29 +112,18 @@ qint64 FormDataIODevice::writeData(const char*, qint64) return -1; } -void FormDataIODevice::setParent(QNetworkReply* reply) -{ - QIODevice::setParent(reply); - - connect(reply, SIGNAL(finished()), SLOT(slotFinished()), Qt::QueuedConnection); -} - bool FormDataIODevice::isSequential() const { return true; } -void FormDataIODevice::slotFinished() -{ - deleteLater(); -} - QNetworkReplyHandler::QNetworkReplyHandler(ResourceHandle* handle, LoadMode loadMode) : QObject(0) - , m_resourceHandle(handle) , m_reply(0) + , m_resourceHandle(handle) , m_redirected(false) , m_responseSent(false) + , m_responseDataSent(false) , m_loadMode(loadMode) , m_shouldStart(true) , m_shouldFinish(false) @@ -151,10 +140,14 @@ QNetworkReplyHandler::QNetworkReplyHandler(ResourceHandle* handle, LoadMode load m_method = QNetworkAccessManager::PostOperation; else if (r.httpMethod() == "PUT") m_method = QNetworkAccessManager::PutOperation; +#if QT_VERSION >= 0x040600 + else if (r.httpMethod() == "DELETE") + m_method = QNetworkAccessManager::DeleteOperation; +#endif else m_method = QNetworkAccessManager::UnknownOperation; - m_request = r.toNetworkRequest(); + m_request = r.toNetworkRequest(m_resourceHandle->getInternal()->m_frame); if (m_loadMode == LoadNormal) start(); @@ -186,8 +179,8 @@ void QNetworkReplyHandler::abort() QNetworkReply* reply = release(); reply->abort(); reply->deleteLater(); - deleteLater(); } + deleteLater(); } QNetworkReply* QNetworkReplyHandler::release() @@ -199,11 +192,25 @@ QNetworkReply* QNetworkReplyHandler::release() // posted meta call events that were the result of a signal emission // don't reach the slots in our instance. QCoreApplication::removePostedEvents(this, QEvent::MetaCall); + m_reply->setParent(0); m_reply = 0; } return reply; } +static bool ignoreHttpError(QNetworkReply* reply, bool receivedData) +{ + int httpStatusCode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); + + if (httpStatusCode == 401 || httpStatusCode == 407) + return true; + + if (receivedData && (httpStatusCode >= 400 && httpStatusCode < 600)) + return true; + + return false; +} + void QNetworkReplyHandler::finish() { m_shouldFinish = (m_loadMode != LoadNormal); @@ -220,23 +227,27 @@ void QNetworkReplyHandler::finish() m_reply = 0; return; } + QNetworkReply* oldReply = m_reply; + if (m_redirected) { resetState(); start(); - } else if (m_reply->error() != QNetworkReply::NoError - // a web page that returns 401/403/404 can still have content - && m_reply->error() != QNetworkReply::ContentOperationNotPermittedError - && m_reply->error() != QNetworkReply::ContentNotFoundError - && m_reply->error() != QNetworkReply::AuthenticationRequiredError - && m_reply->error() != QNetworkReply::ProxyAuthenticationRequiredError) { - QUrl url = m_reply->url(); - ResourceError error(url.host(), m_reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), - url.toString(), m_reply->errorString()); - client->didFail(m_resourceHandle, error); - } else { + } else if (!m_reply->error() || ignoreHttpError(m_reply, m_responseDataSent)) { client->didFinishLoading(m_resourceHandle); + } else { + QUrl url = m_reply->url(); + int httpStatusCode = m_reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); + + if (httpStatusCode) { + ResourceError error("HTTP", httpStatusCode, url.toString(), m_reply->attribute(QNetworkRequest::HttpReasonPhraseAttribute).toString()); + client->didFail(m_resourceHandle, error); + } else { + ResourceError error("QtNetwork", m_reply->error(), url.toString(), m_reply->errorString()); + client->didFail(m_resourceHandle, error); + } } + oldReply->deleteLater(); if (oldReply == m_reply) m_reply = 0; @@ -248,6 +259,9 @@ void QNetworkReplyHandler::sendResponseIfNeeded() if (m_shouldSendResponse) return; + if (m_reply->error() && !ignoreHttpError(m_reply, m_responseDataSent)) + return; + if (m_responseSent || !m_resourceHandle) return; m_responseSent = true; @@ -271,41 +285,34 @@ void QNetworkReplyHandler::sendResponseIfNeeded() } KURL url(m_reply->url()); - String suggestedFilename = filenameFromHTTPContentDisposition(QString::fromAscii(m_reply->rawHeader("Content-Disposition"))); - - if (suggestedFilename.isEmpty()) - suggestedFilename = url.lastPathComponent(); - ResourceResponse response(url, mimeType, m_reply->header(QNetworkRequest::ContentLengthHeader).toLongLong(), - encoding, - suggestedFilename); + encoding, String()); - const bool isLocalFileReply = (m_reply->url().scheme() == QLatin1String("file")); - int statusCode = m_reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); - if (!isLocalFileReply) { - response.setHTTPStatusCode(statusCode); - response.setHTTPStatusText(m_reply->attribute(QNetworkRequest::HttpReasonPhraseAttribute).toByteArray().constData()); + if (url.isLocalFile()) { + client->didReceiveResponse(m_resourceHandle, response); + return; } - else if (m_reply->error() == QNetworkReply::ContentNotFoundError) - response.setHTTPStatusCode(404); + // The status code is equal to 0 for protocols not in the HTTP family. + int statusCode = m_reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); - /* Fill in the other fields - * For local file requests remove the content length and the last-modified - * headers as required by fast/dom/xmlhttprequest-get.xhtml - */ - foreach (QByteArray headerName, m_reply->rawHeaderList()) { + if (url.protocolInHTTPFamily()) { + String suggestedFilename = filenameFromHTTPContentDisposition(QString::fromAscii(m_reply->rawHeader("Content-Disposition"))); - if (isLocalFileReply - && (headerName == "Content-Length" || headerName == "Last-Modified")) - continue; + if (!suggestedFilename.isEmpty()) + response.setSuggestedFilename(suggestedFilename); + else + response.setSuggestedFilename(url.lastPathComponent()); - response.setHTTPHeaderField(QString::fromAscii(headerName), QString::fromAscii(m_reply->rawHeader(headerName))); - } + response.setHTTPStatusCode(statusCode); + response.setHTTPStatusText(m_reply->attribute(QNetworkRequest::HttpReasonPhraseAttribute).toByteArray().constData()); - if (isLocalFileReply) - response.setHTTPHeaderField(QString::fromAscii("Cache-Control"), QString::fromAscii("no-cache")); + // Add remaining headers. + foreach (const QByteArray& headerName, m_reply->rawHeaderList()) { + response.setHTTPHeaderField(QString::fromAscii(headerName), QString::fromAscii(m_reply->rawHeader(headerName))); + } + } QUrl redirection = m_reply->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl(); if (redirection.isValid()) { @@ -318,12 +325,17 @@ void QNetworkReplyHandler::sendResponseIfNeeded() newRequest.setHTTPMethod("GET"); } + // Should not set Referer after a redirect from a secure resource to non-secure one. + if (!newRequest.url().protocolIs("https") && protocolIs(newRequest.httpReferrer(), "https")) + newRequest.clearHTTPReferrer(); + client->willSendRequest(m_resourceHandle, newRequest, response); m_redirected = true; - m_request = newRequest.toNetworkRequest(); - } else { - client->didReceiveResponse(m_resourceHandle, response); + m_request = newRequest.toNetworkRequest(m_resourceHandle->getInternal()->m_frame); + return; } + + client->didReceiveResponse(m_resourceHandle, response); } void QNetworkReplyHandler::forwardData() @@ -347,8 +359,10 @@ void QNetworkReplyHandler::forwardData() if (!client) return; - if (!data.isEmpty()) + if (!data.isEmpty()) { + m_responseDataSent = true; client->didReceiveData(m_resourceHandle, data.constData(), data.length(), data.length() /*FixMe*/); + } } void QNetworkReplyHandler::start() @@ -387,6 +401,12 @@ void QNetworkReplyHandler::start() putDevice->setParent(m_reply); break; } +#if QT_VERSION >= 0x040600 + case QNetworkAccessManager::DeleteOperation: { + m_reply = manager->deleteResource(m_request); + break; + } +#endif case QNetworkAccessManager::UnknownOperation: { m_reply = 0; ResourceHandleClient* client = m_resourceHandle->client(); @@ -421,6 +441,7 @@ void QNetworkReplyHandler::resetState() { m_redirected = false; m_responseSent = false; + m_responseDataSent = false; m_shouldStart = true; m_shouldFinish = false; m_shouldSendResponse = false; diff --git a/src/3rdparty/webkit/WebCore/platform/network/qt/QNetworkReplyHandler.h b/src/3rdparty/webkit/WebCore/platform/network/qt/QNetworkReplyHandler.h index f88ce8ab8..fccc4a698 100644 --- a/src/3rdparty/webkit/WebCore/platform/network/qt/QNetworkReplyHandler.h +++ b/src/3rdparty/webkit/WebCore/platform/network/qt/QNetworkReplyHandler.h @@ -73,6 +73,7 @@ private: ResourceHandle* m_resourceHandle; bool m_redirected; bool m_responseSent; + bool m_responseDataSent; LoadMode m_loadMode; QNetworkAccessManager::Operation m_method; QNetworkRequest m_request; @@ -95,16 +96,12 @@ public: FormDataIODevice(FormData*); ~FormDataIODevice(); - void setParent(QNetworkReply*); bool isSequential() const; protected: qint64 readData(char*, qint64); qint64 writeData(const char*, qint64); -private Q_SLOTS: - void slotFinished(); - private: void moveToNextElement(); diff --git a/src/3rdparty/webkit/WebCore/platform/network/qt/ResourceHandleQt.cpp b/src/3rdparty/webkit/WebCore/platform/network/qt/ResourceHandleQt.cpp index c5816a4ec..b3844bf94 100644 --- a/src/3rdparty/webkit/WebCore/platform/network/qt/ResourceHandleQt.cpp +++ b/src/3rdparty/webkit/WebCore/platform/network/qt/ResourceHandleQt.cpp @@ -35,6 +35,7 @@ #include "ResourceHandleClient.h" #include "ResourceHandleInternal.h" #include "qwebpage_p.h" +#include "qwebframe_p.h" #include "ChromeClientQt.h" #include "FrameLoaderClientQt.h" #include "Page.h" @@ -42,6 +43,9 @@ #include "NotImplemented.h" +#if QT_VERSION >= 0x040500 +#include <QAbstractNetworkCache> +#endif #include <QCoreApplication> #include <QUrl> #if QT_VERSION >= 0x040400 @@ -73,11 +77,10 @@ private: ResourceResponse m_response; ResourceError m_error; Vector<char> m_data; - bool m_finished; + QEventLoop m_eventLoop; }; WebCoreSynchronousLoader::WebCoreSynchronousLoader() - : m_finished(false) { } @@ -93,19 +96,18 @@ void WebCoreSynchronousLoader::didReceiveData(ResourceHandle*, const char* data, void WebCoreSynchronousLoader::didFinishLoading(ResourceHandle*) { - m_finished = true; + m_eventLoop.exit(); } void WebCoreSynchronousLoader::didFail(ResourceHandle*, const ResourceError& error) { m_error = error; - m_finished = true; + m_eventLoop.exit(); } void WebCoreSynchronousLoader::waitForCompletion() { - while (!m_finished) - QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents); + m_eventLoop.exec(QEventLoop::ExcludeUserInputEvents); } ResourceHandleInternal::~ResourceHandleInternal() @@ -129,6 +131,15 @@ bool ResourceHandle::start(Frame* frame) if (!page) return false; + if (!(d->m_user.isEmpty() || d->m_pass.isEmpty())) { + // If credentials were specified for this request, add them to the url, + // so that they will be passed to QNetworkRequest. + KURL urlWithCredentials(d->m_request.url()); + urlWithCredentials.setUser(d->m_user); + urlWithCredentials.setPass(d->m_pass); + d->m_request.setURL(urlWithCredentials); + } + getInternal()->m_frame = static_cast<FrameLoaderClientQt*>(frame->loader()->client())->webFrame(); #if QT_VERSION < 0x040400 return QWebNetworkManager::self()->add(this, getInternal()->m_frame->page()->d->networkInterface); @@ -154,10 +165,28 @@ bool ResourceHandle::loadsBlocked() return false; } -bool ResourceHandle::willLoadFromCache(ResourceRequest& request) +bool ResourceHandle::willLoadFromCache(ResourceRequest& request, Frame* frame) { - notImplemented(); + if (!frame) + return false; + +#if QT_VERSION >= 0x040500 + QNetworkAccessManager* manager = QWebFramePrivate::kit(frame)->page()->networkAccessManager(); + QAbstractNetworkCache* cache = manager->cache(); + + if (!cache) + return false; + + QNetworkCacheMetaData data = cache->metaData(request.url()); + if (data.isValid()) { + request.setCachePolicy(ReturnCacheDataDontLoad); + return true; + } + return false; +#else + return false; +#endif } bool ResourceHandle::supportsBufferedData() @@ -184,6 +213,14 @@ void ResourceHandle::loadResourceSynchronously(const ResourceRequest& request, S } #else ResourceHandleInternal *d = handle.getInternal(); + if (!(d->m_user.isEmpty() || d->m_pass.isEmpty())) { + // If credentials were specified for this request, add them to the url, + // so that they will be passed to QNetworkRequest. + KURL urlWithCredentials(d->m_request.url()); + urlWithCredentials.setUser(d->m_user); + urlWithCredentials.setPass(d->m_pass); + d->m_request.setURL(urlWithCredentials); + } d->m_frame = static_cast<FrameLoaderClientQt*>(frame->loader()->client())->webFrame(); d->m_job = new QNetworkReplyHandler(&handle, QNetworkReplyHandler::LoadNormal); #endif diff --git a/src/3rdparty/webkit/WebCore/platform/network/qt/ResourceRequest.h b/src/3rdparty/webkit/WebCore/platform/network/qt/ResourceRequest.h index af76f61f2..60d32dd0a 100644 --- a/src/3rdparty/webkit/WebCore/platform/network/qt/ResourceRequest.h +++ b/src/3rdparty/webkit/WebCore/platform/network/qt/ResourceRequest.h @@ -31,6 +31,7 @@ QT_BEGIN_NAMESPACE class QNetworkRequest; +class QObject; QT_END_NAMESPACE namespace WebCore { @@ -38,7 +39,7 @@ namespace WebCore { struct ResourceRequest : ResourceRequestBase { ResourceRequest(const String& url) - : ResourceRequestBase(KURL(url), UseProtocolCachePolicy) + : ResourceRequestBase(KURL(ParsedURLString, url), UseProtocolCachePolicy) { } @@ -59,7 +60,7 @@ namespace WebCore { } #if QT_VERSION >= 0x040400 - QNetworkRequest toNetworkRequest() const; + QNetworkRequest toNetworkRequest(QObject* originatingObject) const; #endif private: diff --git a/src/3rdparty/webkit/WebCore/platform/network/qt/ResourceRequestQt.cpp b/src/3rdparty/webkit/WebCore/platform/network/qt/ResourceRequestQt.cpp index c8f6ad598..a183c402d 100644 --- a/src/3rdparty/webkit/WebCore/platform/network/qt/ResourceRequestQt.cpp +++ b/src/3rdparty/webkit/WebCore/platform/network/qt/ResourceRequestQt.cpp @@ -28,17 +28,25 @@ namespace WebCore { -QNetworkRequest ResourceRequest::toNetworkRequest() const +QNetworkRequest ResourceRequest::toNetworkRequest(QObject* originatingFrame) const { QNetworkRequest request; request.setUrl(url()); +#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) + request.setOriginatingObject(originatingFrame); +#endif const HTTPHeaderMap &headers = httpHeaderFields(); for (HTTPHeaderMap::const_iterator it = headers.begin(), end = headers.end(); it != end; ++it) { QByteArray name = QString(it->first).toAscii(); QByteArray value = QString(it->second).toAscii(); - request.setRawHeader(name, value); + // QNetworkRequest::setRawHeader() would remove the header if the value is null + // Make sure to set an empty header instead of null header. + if (!value.isNull()) + request.setRawHeader(name, value); + else + request.setRawHeader(name, ""); } switch (cachePolicy()) { diff --git a/src/3rdparty/webkit/WebCore/platform/network/qt/SocketStreamError.h b/src/3rdparty/webkit/WebCore/platform/network/qt/SocketStreamError.h new file mode 100644 index 000000000..f9641ad33 --- /dev/null +++ b/src/3rdparty/webkit/WebCore/platform/network/qt/SocketStreamError.h @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 THE COPYRIGHT + * OWNER 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 SocketStreamError_h +#define SocketStreamError_h + +#include "SocketStreamErrorBase.h" + +namespace WebCore { + + class SocketStreamError : public SocketStreamErrorBase { + public: + SocketStreamError() { } + explicit SocketStreamError(int errorCode) + : SocketStreamErrorBase(errorCode) + { + } + + }; + +} // namespace WebCore + +#endif // SocketStreamError_h diff --git a/src/3rdparty/webkit/WebCore/platform/network/qt/SocketStreamHandle.h b/src/3rdparty/webkit/WebCore/platform/network/qt/SocketStreamHandle.h new file mode 100644 index 000000000..64139e5cd --- /dev/null +++ b/src/3rdparty/webkit/WebCore/platform/network/qt/SocketStreamHandle.h @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2009 Apple Inc. All rights reserved. + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 THE COPYRIGHT + * OWNER 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 SocketStreamHandle_h +#define SocketStreamHandle_h + +#include "SocketStreamHandleBase.h" + +#include <wtf/PassRefPtr.h> +#include <wtf/RefCounted.h> + +namespace WebCore { + + class AuthenticationChallenge; + class Credential; + class SocketStreamHandleClient; + + class SocketStreamHandle : public RefCounted<SocketStreamHandle>, public SocketStreamHandleBase { + public: + static PassRefPtr<SocketStreamHandle> create(const KURL& url, SocketStreamHandleClient* client) { return adoptRef(new SocketStreamHandle(url, client)); } + + virtual ~SocketStreamHandle(); + + protected: + virtual int platformSend(const char* data, int length); + virtual void platformClose(); + + private: + SocketStreamHandle(const KURL&, SocketStreamHandleClient*); + + // No authentication for streams per se, but proxy may ask for credentials. + void didReceiveAuthenticationChallenge(const AuthenticationChallenge&); + void receivedCredential(const AuthenticationChallenge&, const Credential&); + void receivedRequestToContinueWithoutCredential(const AuthenticationChallenge&); + void receivedCancellation(const AuthenticationChallenge&); + }; + +} // namespace WebCore + +#endif // SocketStreamHandle_h diff --git a/src/3rdparty/webkit/WebCore/platform/network/qt/SocketStreamHandleSoup.cpp b/src/3rdparty/webkit/WebCore/platform/network/qt/SocketStreamHandleSoup.cpp new file mode 100644 index 000000000..6aa33fce2 --- /dev/null +++ b/src/3rdparty/webkit/WebCore/platform/network/qt/SocketStreamHandleSoup.cpp @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 THE COPYRIGHT + * OWNER 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 "SocketStreamHandle.h" + +#include "KURL.h" +#include "Logging.h" +#include "NotImplemented.h" +#include "SocketStreamHandleClient.h" + +namespace WebCore { + +SocketStreamHandle::SocketStreamHandle(const KURL& url, SocketStreamHandleClient* client) + : SocketStreamHandleBase(url, client) +{ + LOG(Network, "SocketStreamHandle %p new client %p", this, m_client); + notImplemented(); +} + +SocketStreamHandle::~SocketStreamHandle() +{ + LOG(Network, "SocketStreamHandle %p delete", this); + setClient(0); + notImplemented(); +} + +int SocketStreamHandle::platformSend(const char*, int) +{ + LOG(Network, "SocketStreamHandle %p platformSend", this); + notImplemented(); + return 0; +} + +void SocketStreamHandle::platformClose() +{ + LOG(Network, "SocketStreamHandle %p platformClose", this); + notImplemented(); +} + +void SocketStreamHandle::didReceiveAuthenticationChallenge(const AuthenticationChallenge&) +{ + notImplemented(); +} + +void SocketStreamHandle::receivedCredential(const AuthenticationChallenge&, const Credential&) +{ + notImplemented(); +} + +void SocketStreamHandle::receivedRequestToContinueWithoutCredential(const AuthenticationChallenge&) +{ + notImplemented(); +} + +void SocketStreamHandle::receivedCancellation(const AuthenticationChallenge&) +{ + notImplemented(); +} + +} // namespace WebCore |