---
title: accept.media_lookup
summary: null
url: >-
  https://www.fastly.com/documentation/reference/vcl/functions/content-negotiation/accept-media-lookup
---

```
STRING accept.media_lookup(STRING requested_media_types, STRING default, STRING range_defaults, STRING accept_header)
```

**Available in:** all subroutines

Selects the best match from a string in the format of an `Accept` header's 
value in the listed media types using the algorithm described in Section 5.3.2 
of [RFC 7231](https://httpwg.org/specs/rfc7231.html#rfc.section.5.3.2).

This function takes the following parameters:

1. a colon-separated list of media types available for the resource,
2. a fallback return value,
3. a colon-separated list of media types, each corresponding to a media type 
   pattern,
4. a string representing an `Accept` header's value.

The matching procedure is case insensitive and matched media types are returned 
verbatim as supplied to the matching function. Values of the first three 
arguments cannot contain variables. Duplicate media types are not allowed 
among the first three arguments.

## Example

```vcl
# We wish `image/jpeg` to return `image/jpeg`.
# We wish `image/png` to return `image/png`.
# We wish `image/*` to return `image/tiff`.
# We wish `text/*` to return `text/html`.
# We wish `*/*` to return `text/plain`.

set beresp.http.media = accept.media_lookup("image/jpeg:image/png",
  "text/plain",
  "image/tiff:text/html",
  req.http.Accept);
```
