Introduction to HTTP
HTTP, the Hypertext Transfer Protocol, is the set of rules browsers and servers use to talk to each other on the web. Every time a page loads, an image appears, or a React app fetches data from an API, an HTTP request goes out and an HTTP response comes back. Understanding that exchange is the base for everything in the networking lessons ahead.
Request and response: one conversation at a time
HTTP follows a client-server model. The client, usually a browser or your JavaScript code, always starts by sending a request. The server processes it and sends back exactly one response. The server does not send unrequested data over plain HTTP; it only answers.
A request names a method (what you want to do, such as GET to read or POST to create), a path (which resource), headers (extra information), and sometimes a body (data you are sending). A response carries a status code, headers, and usually a body such as HTML or JSON.
GET /api/courses/42 HTTP/1.1
Host: example.com
Accept: application/json
HTTP/1.1 200 OK
Content-Type: application/json
Cache-Control: max-age=60
{"id": 42, "title": "Intro to React", "lessons": 18}
The top half is the request, the bottom half the response. In HTTP/1.1 these really are lines of text. Newer versions, HTTP/2 and HTTP/3, send the same information in a more efficient binary form, but the concepts of method, path, headers, status and body stay identical.
What headers are for
Headers are name-value pairs that describe the message. A few you will see constantly:
Content-Typesays what format the body is in, such asapplication/jsonortext/html.Accepttells the server which formats the client would like back.Authorizationcarries credentials, such as a token, for protected routes.Cache-Controltells browsers how long they may reuse a response.
HTTP has no memory
HTTP is stateless: each request is handled on its own, and the server does not automatically remember previous ones. If you log in and then open your profile, the second request has to prove who you are again. That is why apps send cookies or tokens with every request, a topic covered in the authentication section.
HTTP versus HTTPS
HTTPS is HTTP sent through an encrypted TLS connection. The messages are the same, but nobody between the browser and server can read or alter them. Passwords, tokens and personal data must only travel over HTTPS, and browsers now warn users about forms on plain HTTP pages.
A common misunderstanding: the URL is not the whole request
Beginners often think a URL fully describes a request. In fact, the same URL can mean different things depending on the method. GET /api/users lists users, while POST /api/users creates one. Likewise, a request that "fails" in your code might have received a perfectly valid response with an error status. Opening the Network tab in the browser's developer tools and clicking a request shows the method, headers, status and body, and it is the fastest way to see what really happened.
How this connects to React
In a React app, you usually send requests with the built-in fetch function or a library like Axios, often inside useEffect or an event handler. The server is typically a REST API that responds with JSON. The next lessons look at the different methods and at the status codes that tell you whether a request worked.
Key ideas: the client asks, the server answers once; method plus path describe the action; headers describe the message; and every request stands alone.
Ready to master real-world web development?
Learn HTML, CSS3, Bootstrap and JavaScript hands-on with mentor-led sessions.