HTTP Status 300 Multiple Choices

http status 300 multiple choices
10 November 2024

Hello! I want to discuss a very interesting HTTP status code with you: status 300 or "Multiple Choices". This status is used in the HTTP protocol to indicate that the request has multiple potential responses available.

For example, there might be a URL related to a source that is accessible in multiple formats, such as both JSON and XML. Here, the server can return a 300 status code and allow the user to make a choice.

Status 300 is usually accompanied by HTTP headers that indicate various options, for instance, using the header "Location". Consequently, after receiving this response, the client can select one of the suggested options and correct their request to that specific URL.

Just keep in mind that in most cases, browsers handle it automatically, and the user or developer must decide which path to choose. Therefore, alongside not being confused, status 300 often requires that more information is provided for better user experience.

Now, let's take a look at a small example of a 300 response that specifies how this process occurs:


HTTP/1.1 300 Multiple Choices
Location: /index.json
Location: /index.xml
Content-Type: text/html

<html>
<head>
<title>300 Multiple Choices</title>
</head>
<body>
<h1>300 Multiple Choices</h1>
<p>The resource you requested has several representations. Choose one:</p>
<ul>
<li><a href="/index.json">JSON format</a></li>
<li><a href="/index.xml">XML format</a></li>
</ul>
</body>
</html>

Explanation of the code:

HTTP/1.1 300 Multiple Choices
This line indicates that the server has responded to the request with status 300.

Location: /index.json
This header shows one of the available options (in this example, the JSON version of the source).

Location: /index.xml
This header indicates another option (the XML version of the source).

Content-Type: text/html
This specifies that the body of the response is sent in HTML format.

The rest of the HTML code provides a page for the user that contains a list of links for selecting the appropriate option. By doing this, the user or developer can decide which representation to use from the source.

FAQ

?

What does HTTP status 300 Multiple Choices mean?

?

Do browsers handle 300 status automatically?

?

How can I understand that a source has multiple representations?