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

Function parse_set_cookie

libavformat/http.c:1014–1049  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1012}
1013
1014static int parse_set_cookie(const char *set_cookie, AVDictionary **dict)
1015{
1016 char *param, *next_param, *cstr, *back;
1017 char *saveptr = NULL;
1018
1019 if (!set_cookie[0])
1020 return 0;
1021
1022 if (!(cstr = av_strdup(set_cookie)))
1023 return AVERROR(EINVAL);
1024
1025 // strip any trailing whitespace
1026 back = &cstr[strlen(cstr)-1];
1027 while (strchr(WHITESPACES, *back)) {
1028 *back='\0';
1029 if (back == cstr)
1030 break;
1031 back--;
1032 }
1033
1034 next_param = cstr;
1035 while ((param = av_strtok(next_param, ";", &saveptr))) {
1036 char *name, *value;
1037 next_param = NULL;
1038 param += strspn(param, WHITESPACES);
1039 if ((name = av_strtok(param, "=", &value))) {
1040 if (av_dict_set(dict, name, value, 0) < 0) {
1041 av_free(cstr);
1042 return -1;
1043 }
1044 }
1045 }
1046
1047 av_free(cstr);
1048 return 0;
1049}
1050
1051static int parse_cookie(HTTPContext *s, const char *p, AVDictionary **cookies)
1052{

Callers 2

parse_cookieFunction · 0.85
get_cookiesFunction · 0.85

Calls 4

av_strdupFunction · 0.85
av_strtokFunction · 0.85
av_dict_setFunction · 0.85
av_freeFunction · 0.50

Tested by

no test coverage detected