HTTP
Giả lập phản hồi 407 Proxy Authentication Required
The client must first authenticate itself with the proxy.
Xem tài liệu tham khảo đầy đủ →1 Phản hồi HTTP
HTTP/1.1 407 Proxy Authentication Required
Content-Type: application/json
Date: Tue, 25 Feb 2026 12:00:00 GMT
Content-Length: 86
{
"error": "proxy_authentication_required",
"message": "Proxy Authentication Required"
}
2 Kiểm tra với curl
curl -i https://httpbin.org/status/407
3 Trả về 407 Proxy Authentication Required trong Framework của bạn
django
from django.http import JsonResponse
def my_view(request):
return JsonResponse(
{"error": "proxy_authentication_required", "message": "Proxy Authentication Required"},
status=407,
)
flask
from flask import Flask, jsonify
app = Flask(__name__)
@app.route("/endpoint")
def my_endpoint():
return jsonify({"error": "proxy_authentication_required", "message": "Proxy Authentication Required"}), 407
fastapi
from fastapi import FastAPI
from fastapi.responses import JSONResponse
app = FastAPI()
@app.get("/endpoint")
def my_endpoint():
return JSONResponse(
content={"error": "proxy_authentication_required", "message": "Proxy Authentication Required"},
status_code=407,
)
express.js
// Express.js
app.get('/endpoint', (req, res) => {
res.status(407).json({"error": "proxy_authentication_required", "message": "Proxy Authentication Required"});
});
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(407)
.body(Map.of("error", "proxy_authentication_required",
"message", "Proxy Authentication Required"));
}
}
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(407)
json.NewEncoder(w).Encode(map[string]string{
"error": "proxy_authentication_required",
"message": "Proxy Authentication Required",
})
}
ruby on rails
class MyController < ApplicationController
def my_action
render json: {"error": "proxy_authentication_required", "message": "Proxy Authentication Required"},
status: :proxy_authentication_required
end
end
asp.net core
// ASP.NET Core Minimal API
app.MapGet("/endpoint", () =>
Results.Json(
new { error = "proxy_authentication_required", message = "Proxy Authentication Required" },
statusCode: 407
)
);