Intern Track Roadmap

HTTP status codes: success (2xx)

This course covers the 2xx family of HTTP status codes, which signal that a request succeeded. It starts with how status codes work, the five families and the status line. It then explains 200 OK, 201 Created with the Location header, 204 No Content, 202 Accepted for background work and 206 Partial Content for range requests. A decision tree maps HTTP methods to the right code. The last lesson shows how Rails sends and tests these codes with render, head, redirect_to and respond_to.

What you'll learn

  • ✓How status codes, the five families and the status line work
  • ✓When to return 200 OK and when to avoid it
  • ✓How 201 Created and the Location header describe a new resource
  • ✓The rules of 204 No Content and its role in CORS preflight
  • ✓How 202 Accepted and 206 Partial Content handle async jobs and range requests
  • ✓How Rails sets and tests success codes in controllers
Free preview · Lesson 1 5 min read

What are HTTP status codes?

Every time a client (browser, mobile app, API consumer) sends an HTTP request, the server sends back a response. The very first thing in that response is a three-digit number called the status code.

Read the full lesson free →

Curriculum

7 lessons
Type to start searching...