HTTP
Simuler une réponse 302 Found
The resource temporarily resides at a different URL. The client should continue using the original URL for future requests.
Voir la référence complète →1 Réponse HTTP
HTTP/1.1 302 Found Content-Type: application/json Date: Tue, 25 Feb 2026 12:00:00 GMT Location: https://example.com/new-location
2 Tester avec curl
curl -i https://httpbin.org/status/302
3 Retourner 302 Found dans votre framework
django
from django.http import HttpResponse
def my_view(request):
return HttpResponse(status=302) # Found
flask
from flask import Flask
app = Flask(__name__)
@app.route("/endpoint")
def my_endpoint():
return "", 302 # Found
fastapi
from fastapi import FastAPI
from fastapi.responses import Response
app = FastAPI()
@app.get("/endpoint")
def my_endpoint():
return Response(status_code=302) # Found
express.js
// Express.js
app.get('/endpoint', (req, res) => {
res.sendStatus(302); // Found
});
spring boot
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
@RestController
public class MyController {
@GetMapping("/endpoint")
public ResponseEntity<Void> myEndpoint() {
return ResponseEntity
.status(302) // Found
.build();
}
}
go net/http
package main
import "net/http"
func myHandler(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(302) // Found
}
ruby on rails
class MyController < ApplicationController
def my_action
head :found
end
end
asp.net core
// ASP.NET Core Minimal API
app.MapGet("/endpoint", () =>
Results.StatusCode(302) // Found
);