MCPcopy Create free account
hub / github.com/apache/httpd / mime_match

Function mime_match

modules/mappers/mod_negotiation.c:1327–1363  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1325 */
1326
1327static int mime_match(accept_rec *accept_r, var_rec *avail)
1328{
1329 const char *accept_type = accept_r->name;
1330 const char *avail_type = avail->mime_type;
1331 int len = strlen(accept_type);
1332
1333 if ((len == 1 && accept_type[0] == '*')
1334 || (len == 3 && !strncmp(accept_type, "*/*", 3))) {
1335 /* Anything matches star or star/star */
1336 if (avail->mime_stars < 1) {
1337 avail->mime_stars = 1;
1338 }
1339 return 1;
1340 }
1341 else if (len > 2 && accept_type[len - 2] == '/'
1342 && accept_type[len - 1] == '*'
1343 && !strncmp(accept_type, avail_type, len - 2)
1344 && avail_type[len - 2] == '/') {
1345 /* Any subtype matches for type/star */
1346 if (avail->mime_stars < 2) {
1347 avail->mime_stars = 2;
1348 }
1349 return 1;
1350 }
1351 else if (!strcmp(accept_type, avail_type)
1352 || (!strcmp(accept_type, "text/html")
1353 && (!strcmp(avail_type, INCLUDES_MAGIC_TYPE)
1354 || !strcmp(avail_type, INCLUDES_MAGIC_TYPE3)))) {
1355 if (accept_r->level >= avail->level) {
1356 avail->level_matched = avail->level;
1357 avail->mime_stars = 3;
1358 return 1;
1359 }
1360 }
1361
1362 return OK;
1363}
1364
1365/* This code implements a piece of the tie-breaking algorithm between
1366 * variants of equal quality. This piece is the treatment of variants

Callers 1

set_accept_qualityFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected