Changeset 59185 in webkit


Ignore:
Timestamp:
May 11, 2010 4:41:25 PM (14 years ago)
Author:
ap@apple.com
Message:

Reviewed by Brady Eidson.

https://bugs.webkit.org/show_bug.cgi?id=37989
Safari (still) doesn't always send basic credentials preemptively

Test: http/tests/xmlhttprequest/basic-auth-default.html

After fetching credentials from WebCore storage, put them back right away. This will add
default credentials for the directory, since this may be the first time we learn about its
associated protection space.

  • platform/network/cf/ResourceHandleCFNet.cpp: (WebCore::ResourceHandle::didReceiveAuthenticationChallenge): (WebCore::WebCoreSynchronousLoader::didReceiveChallenge):
  • platform/network/mac/ResourceHandleMac.mm: (WebCore::ResourceHandle::didReceiveAuthenticationChallenge): (-[WebCoreSynchronousLoader connection:didReceiveAuthenticationChallenge:]):
Location:
trunk
Files:
8 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r59180 r59185  
     12010-05-11  Alexey Proskuryakov  <ap@apple.com>
     2
     3        Reviewed by Brady Eidson.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=37989
     6        Safari (still) doesn't always send basic credentials preemptively
     7
     8        These resources shouldn't be reused for any other test.
     9
     10        * http/tests/xmlhttprequest/basic-auth-default-expected.txt: Added.
     11        * http/tests/xmlhttprequest/basic-auth-default.html: Added.
     12        * http/tests/xmlhttprequest/resources/basic-auth-default: Added.
     13        * http/tests/xmlhttprequest/resources/basic-auth-default/dir1: Added.
     14        * http/tests/xmlhttprequest/resources/basic-auth-default/dir1/basic-auth.php: Added.
     15        * http/tests/xmlhttprequest/resources/basic-auth-default/dir2: Added.
     16        * http/tests/xmlhttprequest/resources/basic-auth-default/dir2/basic-auth.php: Added.
     17        * http/tests/xmlhttprequest/resources/basic-auth-default/dir2/catch.php: Added.
     18
    1192010-05-11  Jian Li  <jianli@chromium.org>
    220
  • trunk/WebCore/ChangeLog

    r59183 r59185  
     12010-05-11  Alexey Proskuryakov  <ap@apple.com>
     2
     3        Reviewed by Brady Eidson.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=37989
     6        Safari (still) doesn't always send basic credentials preemptively
     7
     8        Test: http/tests/xmlhttprequest/basic-auth-default.html
     9
     10        After fetching credentials from WebCore storage, put them back right away. This will add
     11        default credentials for the directory, since this may be the first time we learn about its
     12        associated protection space.
     13
     14        * platform/network/cf/ResourceHandleCFNet.cpp:
     15        (WebCore::ResourceHandle::didReceiveAuthenticationChallenge):
     16        (WebCore::WebCoreSynchronousLoader::didReceiveChallenge):
     17        * platform/network/mac/ResourceHandleMac.mm:
     18        (WebCore::ResourceHandle::didReceiveAuthenticationChallenge):
     19        (-[WebCoreSynchronousLoader connection:didReceiveAuthenticationChallenge:]):
     20
    1212010-05-11  Kevin Watters  <kevinwatters@gmail.com>
    222
  • trunk/WebCore/platform/network/cf/ResourceHandleCFNet.cpp

    r57995 r59185  
    515515        if (!credential.isEmpty() && credential != d->m_initialCredential) {
    516516            ASSERT(credential.persistence() == CredentialPersistenceNone);
     517            if (challenge.failureResponse().httpStatusCode() == 401) {
     518                // Store the credential back, possibly adding it as a default for this directory.
     519                CredentialStorage::set(credential, challenge.protectionSpace(), d->m_request.url());
     520            }
    517521            RetainPtr<CFURLCredentialRef> cfCredential(AdoptCF, createCF(credential));
    518522            CFURLConnectionUseCredential(d->m_connection.get(), cfCredential.get(), challenge.cfURLAuthChallengeRef());
     
    725729    WebCoreSynchronousLoader* loader = static_cast<WebCoreSynchronousLoader*>(const_cast<void*>(clientInfo));
    726730
     731    CFURLResponseRef urlResponse = (CFURLResponseRef)CFURLAuthChallengeGetFailureResponse(challenge);
     732    CFHTTPMessageRef httpResponse = urlResponse ? CFURLResponseGetHTTPResponse(urlResponse) : 0;
     733
    727734    if (loader->m_user && loader->m_pass) {
    728735        Credential credential(loader->m_user.get(), loader->m_pass.get(), CredentialPersistenceNone);
    729736        RetainPtr<CFURLCredentialRef> cfCredential(AdoptCF, createCF(credential));
    730737       
    731         CFURLResponseRef urlResponse = (CFURLResponseRef)CFURLAuthChallengeGetFailureResponse(challenge);
    732         CFHTTPMessageRef httpResponse = urlResponse ? CFURLResponseGetHTTPResponse(urlResponse) : 0;
    733738        KURL urlToStore;
    734739        if (httpResponse && CFHTTPMessageGetResponseStatusCode(httpResponse) == 401)
     
    746751        if (!credential.isEmpty() && credential != loader->m_initialCredential) {
    747752            ASSERT(credential.persistence() == CredentialPersistenceNone);
     753            if (httpResponse && CFHTTPMessageGetResponseStatusCode(httpResponse) == 401) {
     754                // Store the credential back, possibly adding it as a default for this directory.
     755                CredentialStorage::set(credential, core(CFURLAuthChallengeGetProtectionSpace(challenge)), loader->m_url.get());
     756            }
    748757            RetainPtr<CFURLCredentialRef> cfCredential(AdoptCF, createCF(credential));
    749758            CFURLConnectionUseCredential(conn, cfCredential.get(), challenge);
  • trunk/WebCore/platform/network/mac/ResourceHandleMac.mm

    r58442 r59185  
    544544        if (!credential.isEmpty() && credential != d->m_initialCredential) {
    545545            ASSERT(credential.persistence() == CredentialPersistenceNone);
     546            if (challenge.failureResponse().httpStatusCode() == 401) {
     547                // Store the credential back, possibly adding it as a default for this directory.
     548                CredentialStorage::set(credential, challenge.protectionSpace(), d->m_request.url());
     549            }
    546550            [challenge.sender() useCredential:mac(credential) forAuthenticationChallenge:mac(challenge)];
    547551            return;
     
    10351039        if (!credential.isEmpty() && credential != m_initialCredential) {
    10361040            ASSERT(credential.persistence() == CredentialPersistenceNone);
     1041            if ([[challenge failureResponse] isKindOfClass:[NSHTTPURLResponse class]] && [(NSHTTPURLResponse *)[challenge failureResponse] statusCode] == 401) {
     1042                // Store the credential back, possibly adding it as a default for this directory.
     1043                CredentialStorage::set(credential, core([challenge protectionSpace]), m_url);
     1044            }
    10371045            [[challenge sender] useCredential:mac(credential) forAuthenticationChallenge:challenge];
    10381046            return;
Note: See TracChangeset for help on using the changeset viewer.