HTTP Basics
Terminology
- HTTP Header
- A list of name and value pairs that contain information that a client and server send back and forth to each other.
- Request Header
- The information a client (a browser) sends to a server to request a file or resource.
- Response Header
- The information that the server sends back to the browser.
- Resource
- The file or information that the browser is requesting.
- Request Endpoint (URL)
- The "location" or path of a resource on the server.
- HTTP Method
- An action that represents what the client would like the server to do with a resource. Common methods:
GET
,POST
,PUT
andDELETE
.
Request/Response Cycle
The Request/Response Cycle is the basis for all communication between a browser and a server.
- The browser sends a Request to the server for a file (such as
index.html
or an action (such as submit a form). - The Request is magically routed to the server using many Internet protocols, such as DNS (domain names -> IP addresses) and HTTP.
- The server receives the request and decides what to do based on the:
- Endpoint URL - The "location" of a resource (a file or information) on the server.
- HTTP Method - The action that is requested, based on CRUD operations:
- Create a resource:
GET
Request - Read a resource:
POST
Request - Update a resource:
UPDATE
Request - Delete a resource:
DELETE
Request
- Create a resource:
- The server performs the requested action based on how we've coded our application.
- The server sends a Response back to the client including a:
- File - either static (
index.html
) or dynamically generated JSON (customers.json
). - Response code - usually either:
200 OK
- Success!404 Not Found
- We've all seen these.500 Internal Server Error
- Usually caused by a problem with our code.
- File - either static (