HTTP is the language of the web
In the previous lesson, the browser found a server. HTTP is the protocol it commonly uses to ask that server for something and receive a response. HTTPS is HTTP protected in transit by TLS; POST alone does not encrypt data. HTTPS encrypts communication while it travels, but by itself does not guarantee that a site is trustworthy.
GET /projects/ HTTP/1.1
Host: example.com
Accept: text/html
HTTP/1.1 200 OK
Content-Type: text/html
<html>...</html>A request has a method, a target path, a protocol version, headers, and sometimes a body. A response has a status code, headers, and usually a body. HTTP/2 and HTTP/3 represent messages differently on the network, but these ideas still help you read DevTools.
GET commonly retrieves a resource and should not change server state. Its parameters often appear in the URL. POST commonly sends data for processing and often has a request body, for example when a form creates a project. POST is not the only method that can change state.
Headers and bodies: Headers describe the message. Content-Type: text/html says the body is HTML; Content-Type: application/json says it is JSON. HTTP itself is stateless, so cookies and sessions can help an application remember context; we will return to them in Module 5.
GET /projects/ HTTP/1.1
Host: example.com
Accept: text/html
HTTP/1.1 200 OK
Content-Type: text/html
<html>...</html>In GET /projects/ HTTP/1.1, GET is the method and /projects/ is the path. Host and Accept are request headers. In the response, 200 is the status code, Content-Type is a response header, and the HTML is the response body.
1xx information
2xx success
3xx redirection
4xx client error
5xx server errorYou do not need to memorize every code. Learn the categories, then use DevTools and documentation for details. Common examples are 200 OK, 201 Created, 301 Moved Permanently, 302 Found, 400 Bad Request, 403 Forbidden, 404 Not Found, and 500 Internal Server Error.
request → URL route → view → responseLater, Django URL routing will select a view. A view can return an HTML page for a GET request or process form data sent with POST.
GET and POST have different jobs
GET
Read or retrieve
Ask for a resource without intending to change server state.
GET /projects/?page=2- Data location
- Often URL query parameters; usually no request body.
- Possible server effect
- Should not change state.
- Typical Django use
- Display a page or list of projects.
POST
Send data for processing
Submit data that may create a resource or otherwise change state.
POST /projects/- Data location
- Often a request body, such as form fields.
- Possible server effect
- May change state; it is not automatically secure or encrypted.
- Typical Django use
- Process a form that creates a project.
Method describes intent, not a database command
The HTTP method signals the purpose of a request, not a direct database operation. GET /projects/ asks for a project list. POST /projects/ sends data that may create a project. POST /login/ sends sign-in data, but does not have to create a database record. GET should be for reading; POST may change application state, but does not automatically mean a new database record is written.
HTTPS protects data while it travels. Do not treat GET as HTML-only, POST as automatically safe, or POST data as permanently hidden.
Status-code families
The first digit gives a useful category. Read the specific code when you need more detail.
- 1xxInformationalThe request is being handled; beginners will rarely need these codes.
- 2xxSuccessThe request succeeded, such as 200 OK or 201 Created.
- 3xxRedirectionThe browser is directed elsewhere, such as 301 or 302.
- 4xxClient errorThe request has a problem, such as 400, 403, or 404.
- 5xxServer errorThe server could not complete a valid request, such as 500.
A status code is information, not a verdict about a person. Inspect the request, response, and server logs when you later debug an application.
HTTP in My Project Hub
These are typical situations for the future Django application, not required responses for every implementation.
200 OKOpening the project list.201 CreatedCreating a project through an API.302 FoundRedirecting after a form is processed successfully.404 Not FoundOpening a project that does not exist.403 ForbiddenTrying to access something without enough permission.500 Internal Server ErrorAn unexpected server-side problem.
A common Django form pattern is POST → Redirect → GET: process a form, redirect the browser, then show a page. You will use it later in the Forms and CRUD module.
HTTP detective
What will the browser most likely do after this response?
Read this response before opening the answer.
HTTP/1.1 302 Found
Location: /projects/- A. Show an error because the page does not exist.
- B. Send a new request to
/projects/. - C. Automatically delete the previous project.
Reveal the answer
B is most likely. Status 302 signals a redirect, and the browser will usually follow the Location header by sending a new request to /projects/.
Read an HTTP message step by step
- Read the method and pathThey show what the browser asks for and how it asks.
- Read headers as contextHeaders can identify the host, accepted content, content type, caching, and more.
- Read the response status firstThe status tells you whether to expect success, redirection, a client problem, or a server problem.
Avoid these shortcuts
- POST means encryptedEncryption comes from HTTPS and TLS, not from choosing POST.
- Every non-200 status is a failureA redirect can be expected, and 201 can mean a resource was created successfully.
