HTTP 상태 코드

ClassBinu·2024년 4월 19일

F-lab

목록 보기
9/65

받을 때는 느슨하게, 보낼 때는 날카롭게

클라이언트 오류 응답(400)

  • 400(Bad Request): 클라이언트 오류로 요청 처리할 수 없거나 하지 않을 때
  • 401(Unauthorized): 인증되지 않음
  • 403(Forbidden): 인증은 됐지만 콘텐츠에 대한 엑세스 권한 없음
  • 404(Not Found): 서버가 리소스를 찾을 수 없을 때. URL이 인식되지 않았을 때.
    403대신에 아예 리소스가 없다고 404를 보낼 수도 있음.
  • 409(Conflict): 요청이 서버의 현재 상태와 충돌할 때(e.g. 중복된 사용자 아이디)
  • 418(I'm a teapot): 만우절에 만들어짐. 장난처럼 씀. 차가 아닌 커피를 만들려는 요청을 찻주전자가 거부한다.

418은 뭐냐?ㅋㅋㅋ..

Nest 내장 예외

BadRequestException - 400 Bad Request
UnauthorizedException - 401 Unauthorized
NotFoundException - 404 Not Found
ForbiddenException - 403 Forbidden
NotAcceptableException - 406 Not Acceptable
RequestTimeoutException - 408 Request Timeout
ConflictException - 409 Conflict
GoneException - 410 Gone
HttpVersionNotSupportedException - 505 HTTP Version Not Supported
PayloadTooLargeException - 413 Payload Too Large
UnsupportedMediaTypeException - 415 Unsupported Media Type
UnprocessableEntityException - 422 Unprocessable Entity
InternalServerErrorException - 500 Internal Server Error
NotImplementedException - 501 Not Implemented
ImATeapotException - 418 I'm a Teapot
MethodNotAllowedException - 405 Method Not Allowed
BadGatewayException - 502 Bad Gateway
ServiceUnavailableException - 503 Service Unavailable
GatewayTimeoutException - 504 Gateway Timeout
PreconditionFailedException - 412 Precondition Failed

0개의 댓글