Skip to content

First, What Is It

  • HTTP (HyperText Transfer Protocol): the "ordering process" of the web — the client sends a request (what I want), the server returns a response (here it is).
  • Request/response model: HTTP is one question, one answer; servers never push data unsolicited.
  • Runs over TCP: HTTP runs on TCP (port 80); HTTPS adds a TLS encryption layer (port 443).

Breaking Down the Principle

1. Complete Flow of One HTTP Request

2. Request Message Structure

text
GET /data HTTP/1.1          ← request line: method path version
Host: example.com           ← headers: key-value pairs
Content-Type: application/json
                            ← blank line separates headers from body
{"temp": 25}                ← body (common with POST)

Common methods:

MethodSemanticsTypical use
GETFetch a resourceRead sensor data, web pages
POSTSubmit/createReport data, login
PUTReplace/updateUpdate configuration
DELETERemoveDelete a resource

3. Status Codes: How the Server Answers

CodeMeaningCommon cases
2xxSuccess200 OK
3xxRedirect301/302
4xxClient error404 not found, 401 unauthorized
5xxServer error500 internal server error

4. HTTPS: A Sealed Envelope on HTTP

HTTPS = HTTP + TLS: first a handshake exchanges keys and verifies the certificate, then traffic is encrypted. SDK HTTPS examples involve certificate configuration; a failed server check means no connection.

How the SDK Implements It

An SDK HTTP client GET flow: connect Wi-Fi, get IP, socket to port 80, send the request text, read the response:

c
/* Pseudocode: GET = TCP connection + send request line/headers + read response */
char req[] = "GET /api/data HTTP/1.1\r\nHost: example.com\r\nConnection: close\r\n\r\n";
send(sock, req, strlen(req), 0);
while ((len = recv(sock, buf, sizeof(buf), 0)) > 0) { /* process response body */ }

POST differs by adding Content-Type and a body; the RESTful API server example implements the "server" role on the board, receiving and parsing requests.

Common Exam & Interview Questions

Difference between HTTP and HTTPS?

HTTPS adds a TLS encryption layer between HTTP and TCP, preventing eavesdropping/tampering and verifying the server identity — at the cost of handshake overhead.

Essential difference between GET and POST?

GET fetches resources, parameters usually in the URL; POST submits data, parameters in the body. Semantically GET is "read", POST is "write".

What do 404 and 500 mean?

404: the client asked for a resource that does not exist. 500: an internal server error. Check the path for 404; check the server program for 500.

Why is the blank line in a request important?

It separates headers from the body; the server knows headers end there. Without it, the two cannot be distinguished.

Why should a dev board know HTTP?

Interfacing with cloud platforms/web services, reporting data, fetching configuration, and OTA firmware downloads all use HTTP/S — the basic protocol for IoT devices on the internet.

Have questions?

For any other questions, visit the unified Q&A and discussion board: Ai-Thinker Discussions

Released under the MIT License. Build Time 2026-09-11 14:52:23