MCPcopy Create free account
hub / github.com/apache/httpd / get_digest_rec

Function get_digest_rec

modules/aaa/mod_auth_digest.c:924–1041  ·  view source on GitHub ↗

Parse the Authorization header, if it exists */

Source from the content-addressed store, hash-verified

922
923/* Parse the Authorization header, if it exists */
924static int get_digest_rec(request_rec *r, digest_header_rec *resp)
925{
926 const char *auth_line;
927 apr_size_t l;
928 int vk = 0, vv = 0;
929 char *key, *value;
930
931 auth_line = apr_table_get(r->headers_in,
932 (PROXYREQ_PROXY == r->proxyreq)
933 ? "Proxy-Authorization"
934 : "Authorization");
935 if (!auth_line) {
936 resp->auth_hdr_sts = NO_HEADER;
937 return !OK;
938 }
939
940 resp->scheme = ap_getword_white(r->pool, &auth_line);
941 if (ap_cstr_casecmp(resp->scheme, "Digest")) {
942 resp->auth_hdr_sts = NOT_DIGEST;
943 return !OK;
944 }
945
946 l = strlen(auth_line);
947
948 key = apr_palloc(r->pool, l+1);
949 value = apr_palloc(r->pool, l+1);
950
951 while (auth_line[0] != '\0') {
952
953 /* find key */
954
955 while (apr_isspace(auth_line[0])) {
956 auth_line++;
957 }
958 vk = 0;
959 while (auth_line[0] != '=' && auth_line[0] != ','
960 && auth_line[0] != '\0' && !apr_isspace(auth_line[0])) {
961 key[vk++] = *auth_line++;
962 }
963 key[vk] = '\0';
964 while (apr_isspace(auth_line[0])) {
965 auth_line++;
966 }
967
968 /* find value */
969
970 vv = 0;
971 if (auth_line[0] == '=') {
972 auth_line++;
973 while (apr_isspace(auth_line[0])) {
974 auth_line++;
975 }
976
977 if (auth_line[0] == '\"') { /* quoted string */
978 auth_line++;
979 while (auth_line[0] != '\"' && auth_line[0] != '\0') {
980 if (auth_line[0] == '\\' && auth_line[1] != '\0') {
981 auth_line++; /* escaped char */

Callers 1

parse_hdr_and_update_ncFunction · 0.85

Calls 2

ap_getword_whiteFunction · 0.85
ap_cstr_casecmpFunction · 0.85

Tested by

no test coverage detected