CodingNic

Introduction to Backend Development

HTTP & HTTPS

Introduction to Backend Development 12 min read

HTTP & HTTPS

Objectives

By the end of this lesson, you should be able to:

  • Explain what HTTP is and why it’s the standard protocol for the web
  • Describe the difference between HTTP and HTTPS
  • Read the basic structure of an HTTP request and response

💡 Why this matters: Every client-server interaction in this course happens over HTTP. Express, the framework this entire course builds toward, exists specifically to make handling HTTP requests and responses easier, understanding the protocol itself makes everything Express does afterward click into place.

What HTTP Is

HTTP (HyperText Transfer Protocol) is the agreed-upon format clients and servers use to talk to each other over the web. It defines how a request should be structured, how a response should be structured, and a shared vocabulary (methods, status codes, headers) both sides understand, regardless of what language or framework either side is actually written in.

This shared agreement is what makes the web work at all: a browser written by one company can talk to a server written by a completely different company, in a completely different programming language, because both sides speak HTTP.

The Structure of a Request

An HTTP request has a few key parts:

text
GET /products/42 HTTP/1.1
Host: example.com
Accept: application/json
  • A method (GET here), describing what kind of action is being requested.
  • A path (/products/42), identifying what resource the request is about.
  • Headers (Host, Accept), extra metadata about the request.
  • Optionally, a body, containing data, common with methods like POST.

The Structure of a Response

text
HTTP/1.1 200 OK
Content-Type: application/json

{"id": 42, "name": "Wireless Mouse"}
  • A status code (200 here), a three-digit number summarizing what happened.
  • Headers, metadata about the response, like Content-Type describing the body’s format.
  • A body, the actual content being returned, HTML, JSON, an image, or nothing at all.

HTTP vs HTTPS

HTTPS is HTTP with encryption added (technically, HTTP running over TLS). Plain HTTP sends everything, including passwords and personal data, as plain, readable text, anyone intercepting the traffic (on public Wi-Fi, for instance) can read it directly. HTTPS encrypts the connection, so intercepted traffic is unreadable without the correct key.

Every real, production application should use HTTPS, essentially without exception. Browsers actively warn users when a site is plain HTTP, and many browser features (like the Geolocation API, covered in a later course) are outright disabled on non-HTTPS pages. During local development, it’s normal to use plain HTTP on your own machine, HTTPS becomes essential the moment real user data crosses a real network.

Try It

  1. Explain, in your own words, why HTTP needing to be a shared, agreed-upon format matters for the web working at all.
  2. Identify the method, path, and one header in this request: POST /login HTTP/1.1 with header Content-Type: application/json.
  3. Explain what HTTPS adds on top of plain HTTP, and why it matters specifically when sending a password.

Recap

  • HTTP is the shared protocol clients and servers use to communicate, defining request and response structure.
  • A request has a method, a path, headers, and optionally a body, a response has a status code, headers, and a body.
  • HTTPS adds encryption on top of HTTP, essential for any real application handling real user data.

Next lesson: the full request-response lifecycle, from a click to a rendered page.