summaryrefslogtreecommitdiff
path: root/libavformat/httpauth.c
diff options
context:
space:
mode:
authorMartin Storsjö <martin@martin.st>2012-03-12 13:59:36 +0200
committerMartin Storsjö <martin@martin.st>2012-03-13 10:36:17 +0200
commit8a3360d18ab148fad6b32b4a8e710f84cd9a45d2 (patch)
treead1ca0bb55e9dd2b41dd9839dab89df7d13c3316 /libavformat/httpauth.c
parent7103c8350a1cb0c9fa574d9ccaa09ce5f53dbfe5 (diff)
httpauth: Parse the stale field in digest auth
Signed-off-by: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'libavformat/httpauth.c')
-rw-r--r--libavformat/httpauth.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/libavformat/httpauth.c b/libavformat/httpauth.c
index 4383585db1..c1cf019eda 100644
--- a/libavformat/httpauth.c
+++ b/libavformat/httpauth.c
@@ -57,6 +57,9 @@ static void handle_digest_params(HTTPAuthState *state, const char *key,
} else if (!strncmp(key, "qop=", key_len)) {
*dest = digest->qop;
*dest_len = sizeof(digest->qop);
+ } else if (!strncmp(key, "stale=", key_len)) {
+ *dest = digest->stale;
+ *dest_len = sizeof(digest->stale);
}
}
@@ -93,6 +96,7 @@ void ff_http_auth_handle_header(HTTPAuthState *state, const char *key,
state->auth_type <= HTTP_AUTH_BASIC) {
state->auth_type = HTTP_AUTH_BASIC;
state->realm[0] = 0;
+ state->stale = 0;
ff_parse_key_value(p, (ff_parse_key_val_cb) handle_basic_params,
state);
} else if (av_stristart(value, "Digest ", &p) &&
@@ -100,10 +104,13 @@ void ff_http_auth_handle_header(HTTPAuthState *state, const char *key,
state->auth_type = HTTP_AUTH_DIGEST;
memset(&state->digest_params, 0, sizeof(DigestParams));
state->realm[0] = 0;
+ state->stale = 0;
ff_parse_key_value(p, (ff_parse_key_val_cb) handle_digest_params,
state);
choose_qop(state->digest_params.qop,
sizeof(state->digest_params.qop));
+ if (!av_strcasecmp(state->digest_params.stale, "true"))
+ state->stale = 1;
}
} else if (!strcmp(key, "Authentication-Info")) {
ff_parse_key_value(value, (ff_parse_key_val_cb) handle_digest_update,
@@ -237,6 +244,9 @@ char *ff_http_auth_create_response(HTTPAuthState *state, const char *auth,
{
char *authstr = NULL;
+ /* Clear the stale flag, we assume the auth is ok now. It is reset
+ * by the server headers if there's a new issue. */
+ state->stale = 0;
if (!auth || !strchr(auth, ':'))
return NULL;