| 1012 | } |
| 1013 | |
| 1014 | static 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 | |
| 1051 | static int parse_cookie(HTTPContext *s, const char *p, AVDictionary **cookies) |
| 1052 | { |
no test coverage detected