HTTP
Giả lập phản hồi 101 Switching Protocols
The server understands the Upgrade header field request and indicates which protocol it is switching to.
Xem tài liệu tham khảo đầy đủ →1 Phản hồi HTTP
HTTP/1.1 101 Switching Protocols Content-Type: application/json Date: Tue, 25 Feb 2026 12:00:00 GMT
2 Kiểm tra với curl
curl -i https://httpbin.org/status/101
3 Trả về 101 Switching Protocols trong Framework của bạn
django
from django.http import HttpResponse
def my_view(request):
return HttpResponse(status=101) # Switching Protocols
flask
from flask import Flask
app = Flask(__name__)
@app.route("/endpoint")
def my_endpoint():
return "", 101 # Switching Protocols
fastapi
from fastapi import FastAPI
from fastapi.responses import Response
app = FastAPI()
@app.get("/endpoint")
def my_endpoint():
return Response(status_code=101) # Switching Protocols
express.js
// Express.js
app.get('/endpoint', (req, res) => {
res.sendStatus(101); // Switching Protocols
});
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(101) // Switching Protocols
.build();
}
}
go net/http
package main
import "net/http"
func myHandler(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(101) // Switching Protocols
}
ruby on rails
class MyController < ApplicationController
def my_action
head :switching_protocols
end
end
asp.net core
// ASP.NET Core Minimal API
app.MapGet("/endpoint", () =>
Results.StatusCode(101) // Switching Protocols
);