FreeBSD/contrib/serf/auth/auth.c
/* Dispatch authentication handling. This function matches the possible
   authentication mechanisms with those available. Server and proxy
   authentication are evaluated separately. */
Dispatch authentication handling. This function matches the possible
authentication mechanisms with those available. Server and proxy
authentication are evaluated separately.
Dispatch authentication handling . This function matches the possible authentication mechanisms with those available . Server and proxy authentication are evaluated separately .
static apr_status_t dispatch_auth(int code,
                                  serf_request_t *request,
                                  serf_bucket_t *response,
                                  void *baton,
                                  apr_pool_t *pool)
{
    serf_bucket_t *hdrs;
    if (code == 401 || code == 407) {
        auth_baton_t ab = { 0 };
        const char *auth_hdr;
        ab.hdrs = apr_hash_make(pool);
        ab.pool = pool;
        if (code == 401)
            ab.header = "WWW-Authenticate";
        else
            ab.header = "Proxy-Authenticate";
        hdrs = serf_bucket_response_get_headers(response);
        auth_hdr = serf_bucket_headers_get(hdrs, ab.header);
        if (!auth_hdr) {
            return SERF_ERROR_AUTHN_FAILED;
        }
        serf__log_skt(AUTH_VERBOSE, __FILE__, request->conn->skt,
                      "%s authz required. Response header(s): %s\n",
                      code == 401 ? "Server" : "Proxy", auth_hdr);
        serf_bucket_headers_do(hdrs,
                               store_header_in_dict,
                               &ab);
        return handle_auth_headers(code, baton, ab.hdrs,
                                   request, response, pool);
    }
    return APR_SUCCESS;
}
static apr_status_t dispatch_auth ( int code , serf_request_t * request , serf_bucket_t * response , void * baton , apr_pool_t * pool ) { serf_bucket_t * hdrs ; if ( code == 401 || code == 407 ) { auth_baton_t ab = { 0 } ; const char * auth_hdr ; ab . hdrs = apr_hash_make ( pool ) ; ab . pool = pool ; if ( code == 401 ) ab . header = " " ; else ab . header = " " ; hdrs = serf_bucket_response_get_headers ( response ) ; auth_hdr = serf_bucket_headers_get ( hdrs , ab . header ) ; if ( ! auth_hdr ) { return SERF_ERROR_AUTHN_FAILED ; } serf__log_skt ( AUTH_VERBOSE , __FILE__ , request -> conn -> skt , " \n " , code == 401 ? " " : " " , auth_hdr ) ; serf_bucket_headers_do ( hdrs , store_header_in_dict , & ab ) ; return handle_auth_headers ( code , baton , ab . hdrs , request , response , pool ) ; } return APR_SUCCESS ; }
Dispatch authentication handling.
Dispatch authentication handling .
/* Before iterating over all authn headers, check if there are any. */ /* Store all WWW- or Proxy-Authenticate headers in a dictionary.

           Note: it is possible to have multiple Authentication: headers. We do
           not want to combine them (per normal header combination rules) as that
           would make it hard to parse. Instead, we want to individually parse
           and handle each header in the response, looking for one that we can
           work with.
        */ /* Iterate over all authentication schemes, in order of decreasing
           security. Try to find a authentication schema the server support. */