HTTP

Giả lập phản hồi 416 Range Not Satisfiable

The server cannot serve the requested byte range. The Range header value is outside the resource's size.

Xem tài liệu tham khảo đầy đủ →

1 Phản hồi HTTP

Phản hồi HTTP
HTTP/1.1 416 Range Not Satisfiable
Content-Type: application/json
Date: Tue, 25 Feb 2026 12:00:00 GMT
Content-Length: 70

{
  "error": "range_not_satisfiable",
  "message": "Range Not Satisfiable"
}

2 Kiểm tra với curl

terminal
curl -i https://httpbin.org/status/416

3 Trả về 416 Range Not Satisfiable trong Framework của bạn

django
from django.http import JsonResponse


def my_view(request):
    return JsonResponse(
        {"error": "range_not_satisfiable", "message": "Range Not Satisfiable"},
        status=416,
    )
flask
from flask import Flask, jsonify

app = Flask(__name__)


@app.route("/endpoint")
def my_endpoint():
    return jsonify({"error": "range_not_satisfiable", "message": "Range Not Satisfiable"}), 416
fastapi
from fastapi import FastAPI
from fastapi.responses import JSONResponse

app = FastAPI()


@app.get("/endpoint")
def my_endpoint():
    return JSONResponse(
        content={"error": "range_not_satisfiable", "message": "Range Not Satisfiable"},
        status_code=416,
    )
express.js
// Express.js
app.get('/endpoint', (req, res) => {
  res.status(416).json({"error": "range_not_satisfiable", "message": "Range Not Satisfiable"});
});
spring boot
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.Map;

@RestController
public class MyController {

    @GetMapping("/endpoint")
    public ResponseEntity<Map<String, Object>> myEndpoint() {
        return ResponseEntity
            .status(416)
            .body(Map.of("error", "range_not_satisfiable",
                         "message", "Range Not Satisfiable"));
    }
}
go net/http
package main

import (
    "encoding/json"
    "net/http"
)

func myHandler(w http.ResponseWriter, r *http.Request) {
    w.Header().Set("Content-Type", "application/json")
    w.WriteHeader(416)
    json.NewEncoder(w).Encode(map[string]string{
        "error":   "range_not_satisfiable",
        "message": "Range Not Satisfiable",
    })
}
ruby on rails
class MyController < ApplicationController
  def my_action
    render json: {"error": "range_not_satisfiable", "message": "Range Not Satisfiable"},
           status: :range_not_satisfiable
  end
end
asp.net core
// ASP.NET Core Minimal API
app.MapGet("/endpoint", () =>
    Results.Json(
        new { error = "range_not_satisfiable", message = "Range Not Satisfiable" },
        statusCode: 416
    )
);

Thêm trang giả lập HTTP