HTTP

Hyper Text Transfer Protocol

HTTP is a protocol for transmitting resouces such as HTML.

It follows a client-server model where a client (such as a web browser) opens a connection with a web server and makes a request for a resource (such as the homepage/index.html) and then waits for a response from the server.

Request/Response Cycle

HTTP Message Format

In HTTP/1.1, the client and server communicate via plain text using a similar format:

Start Line
Headers (optional)
(Empty line)
Body (optional)

Request Message

GET / HTTP/1.1
Host: generalassemb.ly
Accept: text/html

Response Message

HTTP/1.1 200 OK
Server: nginx
Date: Wed, 8 Jun 1955 00:00:00 GMT
Content-Type: text/html

<!DOCTYPE html>
<html class="no-js" lang="en">
<head>

HTTP Methods

HTTP Methods describe the operation the client wants the server to do. Common methods include GET, POST, PUT, PATCH, and DELETE.

The GET method is used to fetch (read) data from the server. More on the other methods and their uses on MDN and in future classes.

HTTP Status Codes

HTTP response status codes indicate if an HTTP request has successfully completed or not. Status codes are grouped in five ranges:

RangePurpose

100-199

Informational

200-299

Success

300-399

Redirect

400-499

Client Error

500-599

Server Error

Further Reading

https://developer.mozilla.org/en-US/docs/Web/HTTP/

Last updated