Changeset 112 for Mulberry

Show
Ignore:
Timestamp:
10/28/07 23:38:23 (1 year ago)
Author:
daboo
Message:

Fix digest.

Location:
Mulberry/branches/v4.1d1/Sources_Common/HTTP/HTTPClient
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • Mulberry/branches/v4.1d1/Sources_Common/HTTP/HTTPClient/CHTTPAuthorizationDigest.cpp

    r96 r112  
    7070} 
    7171 
    72 void CHTTPAuthorizationDigest::ParseAuthenticateHeader(const cdstring& auth) 
    73 { 
    74         // Strip any space 
    75         cdstring temp(auth); 
    76         char* p = temp.c_str_mod(); 
    77          
    78         // Must have digest token 
    79         if (::stradvtokcmp(&p, "Digest") != 0) 
    80                 return; 
    81          
    82         // Get each name/value pair 
    83         while(true) 
    84         { 
    85                 char* name = ::strgettokenstr(&p, SPACE_TAB "="); 
    86                 if ((name == NULL) || (*p == 0)) 
    87                         return; 
    88                  
    89                 char* value = ::strgettokenstr(&p, SPACE_TAB ","); 
    90                 if (value == NULL) 
    91                         return; 
    92                  
    93                 if (::strcmpnocase(name, "realm") == 0) 
     72void CHTTPAuthorizationDigest::ParseAuthenticateHeader(const cdstrvect& hdrs) 
     73{ 
     74        for(cdstrvect::const_iterator iter = hdrs.begin(); iter != hdrs.end(); iter++) 
     75        { 
     76                // Strip any space 
     77                cdstring temp(*iter); 
     78                char* p = temp.c_str_mod(); 
     79                 
     80                // Must have digest token 
     81                if (::stradvtokcmp(&p, "Digest") != 0) 
     82                        continue; 
     83                 
     84                // Get each name/value pair 
     85                while(true) 
    9486                { 
    95                         mRealm = value; 
     87                        char* name = ::strgettokenstr(&p, SPACE_TAB "="); 
     88                        if ((name == NULL) || (*p == 0)) 
     89                                return; 
     90                         
     91                        char* value = ::strgettokenstr(&p, SPACE_TAB ","); 
     92                        if (value == NULL) 
     93                                return; 
     94                         
     95                        if (::strcmpnocase(name, "realm") == 0) 
     96                        { 
     97                                mRealm = value; 
     98                        } 
     99                        else if (::strcmpnocase(name, "domain") == 0) 
     100                        { 
     101                                mDomain = value; 
     102                        } 
     103                        else if (::strcmpnocase(name, "nonce") == 0) 
     104                        { 
     105                                mNonce = value; 
     106                        } 
     107                        else if (::strcmpnocase(name, "opaque") == 0) 
     108                        { 
     109                                mOpaque = value; 
     110                        } 
     111                        else if (::strcmpnocase(name, "stale") == 0) 
     112                        { 
     113                                mStale = (::strcmpnocase(value, "false") != 0); 
     114                        } 
     115                        else if (::strcmpnocase(name, "algorithm") == 0) 
     116                        { 
     117                                mAlgorithm = value; 
     118                        } 
     119                        else if (::strcmpnocase(name, "qop") == 0) 
     120                        { 
     121                                mQop = value; 
     122                        } 
     123                        else 
     124                        { 
     125                                // Unknown token - ignore 
     126                        } 
     127                         
     128                        // Punt over comma 
     129                        while((*p != 0) && (*p == ',')) 
     130                                p++; 
    96131                } 
    97                 else if (::strcmpnocase(name, "domain") == 0) 
    98                 { 
    99                         mDomain = value; 
    100                 } 
    101                 else if (::strcmpnocase(name, "nonce") == 0) 
    102                 { 
    103                         mNonce = value; 
    104                 } 
    105                 else if (::strcmpnocase(name, "opaque") == 0) 
    106                 { 
    107                         mOpaque = value; 
    108                 } 
    109                 else if (::strcmpnocase(name, "stale") == 0) 
    110                 { 
    111                         mStale = (::strcmpnocase(value, "false") != 0); 
    112                 } 
    113                 else if (::strcmpnocase(name, "algorithm") == 0) 
    114                 { 
    115                         mAlgorithm = value; 
    116                 } 
    117                 else if (::strcmpnocase(name, "qop") == 0) 
    118                 { 
    119                         mQop = value; 
    120                 } 
    121                 else 
    122                 { 
    123                         // Unknown token - ignore 
    124                 } 
    125                  
    126                 // Punt over comma 
    127                 while((*p != 0) && (*p == ',')) 
    128                         p++; 
     132                 
     133                break; 
    129134        } 
    130135} 
  • Mulberry/branches/v4.1d1/Sources_Common/HTTP/HTTPClient/CHTTPAuthorizationDigest.h

    r19 r112  
    4141                mClientCount = 0; 
    4242        } 
    43         CHTTPAuthorizationDigest(const cdstring& user, const cdstring& pswd, const cdstring& www_authenticate) 
     43        CHTTPAuthorizationDigest(const cdstring& user, const cdstring& pswd, const cdstrvect& www_authenticate) 
    4444        { 
    4545                mUser = user; 
     
    5151        virtual ~CHTTPAuthorizationDigest() {} 
    5252 
    53         void SetDetails(const cdstring& user, const cdstring& pswd, const cdstring& www_authenticate) 
     53        void SetDetails(const cdstring& user, const cdstring& pswd, const cdstrvect& www_authenticate) 
    5454        { 
    5555                mUser = user; 
     
    7676        cdstring                mResponse; 
    7777 
    78         void ParseAuthenticateHeader(const cdstring& auth); 
     78        void ParseAuthenticateHeader(const cdstrvect& hdrs); 
    7979        void GenerateResponse(const CHTTPRequestResponse* request); 
    8080}; 
  • Mulberry/branches/v4.1d1/Sources_Common/HTTP/HTTPClient/CHTTPRequestResponse.cpp

    r86 r112  
    330330} 
    331331 
     332cdstrvect& CHTTPRequestResponse::GetResponseHeaders(const cdstring& hdr, cdstrvect& hdrs) const 
     333{ 
     334        if (mHeaders.count(hdr)) 
     335        { 
     336                for(cdstrmultimapcasei::const_iterator iter = mHeaders.lower_bound(hdr); iter != mHeaders.upper_bound(hdr); iter++) 
     337                        hdrs.push_back((*iter).second); 
     338        } 
     339 
     340        return hdrs; 
     341} 
     342 
    332343bool CHTTPRequestResponse::IsRedirect() const 
    333344{ 
  • Mulberry/branches/v4.1d1/Sources_Common/HTTP/HTTPClient/CHTTPRequestResponse.h

    r86 r112  
    206206 
    207207        const cdstring& GetResponseHeader(const cdstring& hdr) const; 
    208  
     208         
     209        cdstrvect& GetResponseHeaders(const cdstring& hdr, cdstrvect& hdrs) const; 
     210         
    209211        void DoRequestSync(); 
    210212