COMPUTER ENGINEER

Jump to examples
Blog
HTTP / HTTPS / TLS6 min study
11/ 70

Status codes · 1xx–5xx

Status code families and error semantics

Success, redirects and errors require different handling.

UnderstandStudy an examplePractise

Understand the concept

1xx indicates interim information, 2xx success, 3xx redirects or conditional-cache outcomes, 4xx request-related problems and 5xx server failure. 201 means creation, 202 accepted but not completed work, and 204 success without content. Acceptance does not guarantee eventual success.

Common distinctions include malformed requests, missing valid authentication, forbidden access, missing resources, state conflicts and unsupported media types. A 401 response should be designed with the authentication challenge contract.

502, 503 and 504 describe different gateway or availability failures. Returning 200 for every error obscures monitoring and client behaviour. Never expose stack traces or secrets in public error bodies.

WHEN TO USE IT

Build useful client handling and monitoring rules.

COMMON PITFALL

Treating 401 and 403 as the same login failure.

01 / PRACTICE

One topic. Three levels of depth.

HTTP / illustrative example
HTTP/1.1 201 Created
Location: /orders/123

Identifies the newly created resource.

This page does not send requests to external servers. Messages are readable HTTP/1.1 illustrations, not HTTP/2 or HTTP/3 wire dumps. example.test is reserved for examples. Run commands and JavaScript only in your own test environment; never publish real tokens or cookies.

02 / YOUR TURN

Try it yourself first.

Should a 204 response contain a JSON body?

Show the solution and explanation
Worked solution
204 = no response content

No. Clients should not expect content; use an appropriate other success response for JSON.