MDN Web Docs

Status

http

300 Multiple Choices

Examples

300 response with list of resources

The following example demonstrates a Transparent Content Negotiation request-response exchange. An Apache server offers multiple variants of a resource defined in a type map; index.html.en for a resource in English, and index.html.fr for a French version:

http

URI: index.html.en
Content-Language: en
URI: index.html.fr
Content-Language: fr

A Negotiate: trans request header indicates that the client wants to use TCN to choose a resource. Poor browser support for this mechanism means a user agent such as curl must be used instead:

bash

 curl -v -H "Negotiate: trans" http://localhost/index

This produces the following request:

http

GET /index HTTP/1.1
Host: localhost
User-Agent: curl/8.7.1
Accept: */*
Negotiate: trans

We receive a 300 response with details of different representations of the requested resource:

http

HTTP/1.1 300 Multiple Choices
Date: Fri, 30 Aug 2024 09:21:48 GMT
Server: Apache/2.4.59 (Unix)
Alternates: {"index.html.en" 1 {type text/html} {language en} {length 48}}, {"index.html.fr" 1 {type text/html} {language fr} {length 45}}
Vary: negotiate,accept-language
TCN: list
Content-Length: 419
Content-Type: text/html; charset=iso-8859-1
<html><head>
<title>300 Multiple Choices</title>
</head><body>
<h1>Multiple Choices</h1>
Available variants:
<ul>
<li><a href="index.html.en">index.html.en</a> , type text/html, language en</li>
<li><a href="index.html.fr">index.html.fr</a> , type text/html, language fr</li>
</ul>
</body></html>

Specifications

Specification
HTTP Semantics
# status.300

See also

Help improve MDN

Yes No

Learn how to contribute

This page was last modified on by MDN contributors.

Read the original on developer.mozilla.org ↗