HTTP 226 IM Used
Overview
The HTTP 226 IM Used
status code is used to indicate that the server has fulfilled a GET request for the resource, and the response is a representation of the result of one or more instance-manipulation operations applied to the current instance.
Purpose
The HTTP 226 response is typically used in conjunction with the Instance Manipulations (IM) header to indicate partial updates to a cached resource.
Usage
Client Behavior:
- Send Request: The client sends a GET request with the IM header indicating support for instance manipulations.
- Receive Response: The client receives the HTTP 226 status code along with the updated content.
Server Behavior:
- Process Request: The server processes the request and applies instance manipulations to the resource.
- Send Response: The server sends a
226 IM Used
response with the result of the applied manipulations.
Scenarios
- Delta Encoding: Often used in delta encoding scenarios to send updates to previously cached data.
- Partial Updates: Utilized to send partial updates to clients to reduce bandwidth and improve efficiency.
Sequence Diagram
Illustrating the process for an HTTP 226 response:
sequenceDiagram participant Client participant Server as Web Server Note over Client: Client sends a GET request with IM header Client->>Server: GET /resource HTTP/1.1 Note over Server: Server applies instance manipulations Server->>Client: HTTP/1.1 226 IM Used
Curl Request and Response Example
Requesting a resource with instance manipulations using Curl:
curl -i -H "A-IM: feed" http://example.com/resource
# Expected response: HTTP/1.1 226 IM Used
PHP cURL Request and Response Example
PHP script using cURL to request a resource with instance manipulations:
<?php
$ch = curl_init('http://example.com/resource');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('A-IM: feed'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
if (curl_getinfo($ch, CURLINFO_HTTP_CODE) == 226) {
echo "Resource with instance manipulations received.";
}
curl_close($ch);
?>
Python Request and Response Example
Python script to send a GET request with instance manipulations and handle a 226 IM Used response:
import requests
headers = {'A-IM': 'feed'}
response = requests.get('http://example.com/resource', headers=headers)
if response.status_code == 226:
print("Resource with instance manipulations received")
Apache Configuration for HTTP 226 IM Used
Configuring Apache to support HTTP 226 responses for instance manipulations:
<VirtualHost *:80>
ServerName example.com
# Configuration directives for instance manipulations...
</VirtualHost>
NGINX Configuration for HTTP 226 IM Used
Setting up NGINX to handle HTTP 226 responses for resources with instance manipulations:
server {
listen 80;
server_name example.com;
location /resource {
# Directives for handling instance manipulations
# ...
}
}
HTTP 208 Already Reported (WebDAV) HTTP 300 Multiple Choices