@@ -434,25 +434,18 @@ serf__validate_response_digest_auth(const serf__authn_scheme_t *scheme,
434434 serf_bucket_t * response ,
435435 apr_pool_t * pool )
436436{
437- const char * key ;
438- char * auth_attr ;
439- char * nextkv ;
437+ const char * const info_hdr = SERF__INFO_HEADER_FROM_PEER (peer );
440438 const char * rspauth = NULL ;
441439 const char * qop = NULL ;
442440 const char * nc_str = NULL ;
443- serf_bucket_t * hdrs ;
444441 serf_context_t * ctx = conn -> ctx ;
442+ serf_bucket_t * hdrs ;
443+ const char * auth_attr ;
444+ apr_hash_t * auth_params ;
445445 apr_status_t status ;
446446
447447 hdrs = serf_bucket_response_get_headers (response );
448-
449- /* Need a copy cuz we're going to write NUL characters into the string. */
450- if (peer == HOST )
451- auth_attr = apr_pstrdup (pool ,
452- serf_bucket_headers_get (hdrs , "Authentication-Info" ));
453- else
454- auth_attr = apr_pstrdup (pool ,
455- serf_bucket_headers_get (hdrs , "Proxy-Authentication-Info" ));
448+ auth_attr = serf_bucket_headers_get (hdrs , info_hdr );
456449
457450 /* If there's no Authentication-Info header there's nothing to validate. */
458451 if (! auth_attr )
@@ -462,35 +455,10 @@ serf__validate_response_digest_auth(const serf__authn_scheme_t *scheme,
462455 Ex. rspauth="8a4b8451084b082be6b105e2b7975087",
463456 cnonce="346531653132652d303033392d3435", nc=00000007,
464457 qop=auth */
465- for ( ; (key = apr_strtok (auth_attr , "," , & nextkv )) != NULL ; auth_attr = NULL ) {
466- char * val ;
467-
468- val = strchr (key , '=' );
469- if (val == NULL )
470- continue ;
471- * val ++ = '\0' ;
472-
473- /* skip leading spaces */
474- while (* key == ' ' )
475- key ++ ;
476-
477- /* If the value is quoted, then remove the quotes. */
478- if (* val == '"' ) {
479- apr_size_t last = strlen (val ) - 1 ;
480-
481- if (val [last ] == '"' ) {
482- val [last ] = '\0' ;
483- val ++ ;
484- }
485- }
486-
487- if (strcmp (key , "rspauth" ) == 0 )
488- rspauth = val ;
489- else if (strcmp (key , "qop" ) == 0 )
490- qop = val ;
491- else if (strcmp (key , "nc" ) == 0 )
492- nc_str = val ;
493- }
458+ auth_params = serf__parse_authn_parameters (auth_attr , pool );
459+ rspauth = apr_hash_get (auth_params , "rspauth" , 7 );
460+ qop = apr_hash_get (auth_params , "qop" , 3 );
461+ nc_str = apr_hash_get (auth_params , "nc" , 2 );
494462
495463 if (rspauth ) {
496464 const char * ha2 , * tmp , * resp_hdr_hex ;
0 commit comments