Quickly test your code with various HTTP response codes. Simply make a request to the endpoint with your desired response code.
Simply append the desired HTTP status code to the URL (e.g., /404) to simulate that specific response. Here's how you can use it:
curl -i https://responsecode.com/404
Here is example response from the tool::
HTTP/1.1 404 Not Found
Content-Type: text/plain; charset=UTF-8
Content-Length: 13
404 Not Found
Here are examples demonstrating how to format the response in JSON, set custom HTTP response headers, and the supported HTTP methods:
To receive a response in JSON format rather than text/plain, make sure the Accept header in your HTTP request explicitly specifies application/json, example:
curl -i -H "Accept: application/json" https://responsecode.com/200
To send extra HTTP headers back to the client, you can include them in the HTTP request, prefixed with 'X-Custom-'. For instance, an HTTP request might include a header like this:
X-Custom-Key: Value
This will attach the following HTTP header to the HTTP response.
Key: Value
However, the following HTTP headers are predefined and cannot be modified: Accept, Allow, Content-Type, Content-Length, Date, Strict-Transport-Security
The following HTTP methods are supported:
GET, POST, PUT, HEAD, PATCH, DELETE, OPTIONS
All endpoints are CORS-enabled, allowing requests from any origin, utilizing most HTTP methods, and supporting various HTTP headers with this service.
Below are examples showing how to use ResponseCode.com to test HTTP response codes using different programming languages:
curl -i https://responsecode.com/200
import requests
response = requests.get('https://responsecode.com/500')
print(response.status_code)
const https = require('https');
https.get('https://responsecode.com/404', (resp) => {
console.log('Status Code:', resp.statusCode);
}).on('error', (err) => {
console.error('Error:', err);
});
<?php
$curl = curl_init('https://responsecode.com/401');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, true);
curl_setopt($curl, CURLOPT_NOBODY, true);
curl_exec($curl);
// Get the status code
$status_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
echo 'Status Code: ' . $status_code;
curl_close($curl);
The HTTP Response Code Testing Tool is under constant development and improvements will be made over time.
When you send data or queries to this website or its API, we usually don't keep any of it. If you send Request Body messages, we don't save those either. The only time we might keep something is if something goes wrong unexpectedly, and then we might keep some header info just to figure out what happened. But after we're done, we get rid of it completely.
There might be bugs. Even though we try our best to keep everything running smoothly and make sure all the information is right, we can't promise that everything will be perfect. This is a project I do for fun, so remember that when you use it, you're doing so at your own risk.