MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / ff_http_auth_create_response

Function ff_http_auth_create_response

libavformat/httpauth.c:288–320  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

286}
287
288char *ff_http_auth_create_response(HTTPAuthState *state, const char *auth,
289 const char *path, const char *method)
290{
291 char *authstr = NULL;
292
293 if (!auth || !strchr(auth, ':'))
294 return NULL;
295
296 if (state->auth_type == HTTP_AUTH_BASIC) {
297 int auth_b64_len = (strlen(auth) + 2) / 3 * 4 + 1;
298 int len = auth_b64_len + 30;
299 char *ptr;
300 authstr = av_malloc(len);
301 if (!authstr)
302 return NULL;
303 snprintf(authstr, len, "Authorization: Basic ");
304 ptr = authstr + strlen(authstr);
305 av_base64_encode(ptr, auth_b64_len, auth, strlen(auth));
306 av_strlcat(ptr, "\r\n", len);
307 } else if (state->auth_type == HTTP_AUTH_DIGEST) {
308 char *username = av_strdup(auth), *password;
309
310 if (!username)
311 return NULL;
312
313 if ((password = strchr(username, ':'))) {
314 *password++ = 0;
315 authstr = make_digest_auth(state, username, password, path, method);
316 }
317 av_free(username);
318 }
319 return authstr;
320}
321

Callers 2

http_connectFunction · 0.85

Calls 6

av_mallocFunction · 0.85
av_base64_encodeFunction · 0.85
av_strlcatFunction · 0.85
av_strdupFunction · 0.85
make_digest_authFunction · 0.85
av_freeFunction · 0.85

Tested by

no test coverage detected