Skip to the workspace
Pebellslearn by building
General Development Skills  ›  Capstone Project

HTTP and HTTPS — The Conversation Your API Has

HTTP / HTTPs Protocol 14 minEvery web request is a method and a path sent by a client, answered by a status code and a body, and HTTPS encrypts that conversation with TLS.

aspnet core / HTTP and HTTPS — The Conversation Your API Has

Explore each scene at your own pace.

01 · The rule

The rule

HTTP and HTTPS — The Conversation Your API Has

ASP.NET Core spends its entire life doing one thing: reading HTTP requests and writing HTTP responses. When a phone app asks ReadingRoom for a book, it sends a few lines of text and gets a few lines back. If you can read those lines, you can debug almost any web bug.

The rule

Request: method, path, headers, body. Response: status, headers, body.

A request to ReadingRoom looks like this:

POST /books HTTP/1.1
Host: api.readingroom.example
Content-Type: application/json

{ "title": "Dune", "author": "Frank Herbert" }

And the response:

HTTP/1.1 201 Created
Location: /books/7
Content-Type: application/json

{ "id": 7, "title": "Dune", "author": "Frank Herbert" }

Methods state intent: GET reads, POST creates, PUT replaces, PATCH changes part, DELETE removes. Status codes group by first digit:

  • 2xx success — 200 OK, 201 Created, 204 No Content
  • 3xx go elsewhere — 301, 302, 304 Not Modified
  • 4xx the client got it wrong — 400 Bad Request, 401 Unauthorized, 403 Forbidden, 404 Not Found
  • 5xx the server failed — 500 Internal Server Error, 503 Service Unavailable

HTTP itself is plain text anyone on the network can read. HTTPS is HTTP inside a TLS connection: encrypted, and the server proves its identity with a certificate. ASP.NET Core templates call app.UseHttpsRedirection() to send plain-HTTP visitors to HTTPS, and dotnet dev-certs https --trust sets up a local certificate.

Scene 1 of 5
Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.