| 170 | } |
| 171 | |
| 172 | static int is_alternate_allowed(const char *url) |
| 173 | { |
| 174 | const char *protocols[] = { |
| 175 | "http", "https", "ftp", "ftps" |
| 176 | }; |
| 177 | int i; |
| 178 | |
| 179 | if (http_follow_config != HTTP_FOLLOW_ALWAYS) { |
| 180 | warning("alternate disabled by http.followRedirects: %s", url); |
| 181 | return 0; |
| 182 | } |
| 183 | |
| 184 | for (i = 0; i < ARRAY_SIZE(protocols); i++) { |
| 185 | const char *end; |
| 186 | if (skip_prefix(url, protocols[i], &end) && |
| 187 | starts_with(end, "://")) |
| 188 | break; |
| 189 | } |
| 190 | |
| 191 | if (i >= ARRAY_SIZE(protocols)) { |
| 192 | warning("ignoring alternate with unknown protocol: %s", url); |
| 193 | return 0; |
| 194 | } |
| 195 | if (!is_transport_allowed(protocols[i], 0)) { |
| 196 | warning("ignoring alternate with restricted protocol: %s", url); |
| 197 | return 0; |
| 198 | } |
| 199 | |
| 200 | return 1; |
| 201 | } |
| 202 | |
| 203 | static void process_alternates_response(void *callback_data) |
| 204 | { |
no test coverage detected