HTTP 509 Bandwidth Limit Exceeded (Apache)
Overview
The HTTP 509 Bandwidth Limit Exceeded
status code is a non-standard status code that may be used by some servers to indicate that the client’s allocated bandwidth limit has been exceeded.
Purpose
The HTTP 509 response is used to inform the client that the bandwidth limit allocated to them has been exceeded, and as a result, the server is unable to fulfill the request.
Usage
Client Behavior:
- Send Request: The client sends a request that exceeds the allocated bandwidth limit.
- Receive Response: The client receives an HTTP 509 status code indicating the bandwidth limit has been exceeded.
Server Behavior:
- Exceeded Bandwidth Limit: The server identifies that the client has exceeded its allocated bandwidth limit.
- Send Response: The server sends a
509 Bandwidth Limit Exceeded
response to the client.
Scenarios
- Bandwidth Quota: Commonly used in scenarios where a server enforces bandwidth quotas for clients.
Sequence Diagram
Illustrating the process for an HTTP 509 response:
sequenceDiagram participant Client participant Server Note over Client: Step 1: Client sends a request exceeding bandwidth limit Client->>Server: GET /resource HTTP/1.1 (Step 1) Note over Server: Step 2: Server detects bandwidth limit exceeded Server-->>Client: HTTP/1.1 509 Bandwidth Limit Exceeded (Step 2)
Curl Request and Response Example
Sending a request using Curl that exceeds the bandwidth limit:
curl -i http://example.com/resource
# Expected response: HTTP/1.1 509 Bandwidth Limit Exceeded
PHP cURL Request and Response Example
PHP script using cURL to handle a 509 Bandwidth Limit Exceeded response:
<?php
$ch = curl_init('http://example.com/resource');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
if (curl_getinfo($ch, CURLINFO_HTTP_CODE) == 509) {
echo "Bandwidth Limit Exceeded";
}
curl_close($ch);
?>
Python Request and Response Example
Python script sending a request that exceeds the bandwidth limit and handling a 509 Bandwidth Limit Exceeded response:
import requests
response = requests.get('http://example.com/resource')
if response.status_code == 509:
print("Bandwidth Limit Exceeded")
Apache Configuration for HTTP 509 Bandwidth Limit Exceeded
Configuring Apache to handle 509 errors:
# Apache Configuration Example
ErrorDocument 509 "Bandwidth Limit Exceeded"
NGINX Configuration for HTTP 509 Bandwidth Limit Exceeded
NGINX configuration for handling 509 errors:
# NGINX Configuration Example
error_page 509 /509.html;
location = /509.html {
internal;
return 509 "Bandwidth Limit Exceeded";
}
HTTP 508 Loop Detected (WebDAV) HTTP 510 Not Extended