HTTP Response Code Testing Tool

Quickly test your code with various HTTP response codes. Simply make a request to the endpoint with your desired response code.

Usage Example

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 a list of supported HTTP Status Codes. You can use tools like `curl`, Postman, or your own code.

Response Example

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

Custom Options

Here are examples demonstrating how to format the response in JSON, set custom HTTP response headers, and the supported HTTP methods:

JSON Response

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
The response body will be formatted as JSON, with the appropriate HTTP header
Content-Type: application/json

Custom HTTP Response Headers

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

Supported HTTP methods

The following HTTP methods are supported:

GET, POST, PUT, HEAD, PATCH, DELETE, OPTIONS

CORS Support

All endpoints are CORS-enabled, allowing requests from any origin, utilizing most HTTP methods, and supporting various HTTP headers with this service.

Code Examples

Below are examples showing how to use ResponseCode.com to test HTTP response codes using different programming languages:

Curl

curl -i https://responsecode.com/200

Python (Requests)

import requests
response = requests.get('https://responsecode.com/500')
print(response.status_code)

Node.js (https module)

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)

<?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);
                    

Disclaimer

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.