HTTP Protocol Cheat Sheet

Suresh Kumar
3 min readJul 25, 2023

--

HTTP(Hyper Text Transfer Protocol) is used in Client & Web Server interactions in distributed, Multi-Tier applications, as shown below.

REST API & HTTP Cheat Sheet
REST API & HTTP Cheat Sheet

HTTP is one of the most widely used Network Protocol.

As known HTTP is a request/response based protocol, where a Web Client(Web Browser, POST Man, Mobile App, etc…) sends an HTTP request and Web Server(such as Apache Tomcat, Websphere, Web Logic, etc…) responds with response data along with HTTP Status code

HTTP Request contains:

  1. URL(with Path Variables, Query Parameters)
  2. HTTP Method
  3. HTTP Headers
  4. Request Body(in XML or JSON Format or even in binary)
  5. Cookie(Optional)

Path Variables in Http Request:

http://someurl.com/10/20

Query Parameters in Http Request:

http://someurl.com?age=25&gender=male

HTTP Response contains:

  1. HTTP status code
  2. HTTP Headers
  3. Response Body(in XML or JSON Format)

HTTP Methods: Below are commonly used HTTP Methods, (Consider Flight Ticket as a resource here)

GET — to retrieve a resource(retrieve a specific Flight Ticket details, which was already booked earlier)

POST — to create a resource(to book a new Flight Ticket)

PUT — to update a resource(to update Journey Date of a Flight Ticket)

DELETE — to delete a resource(to Cancel a Flight Ticket)

PURGE — to delete resource from Caching Servers

TRACE — Web Server sends a received Request back to Client, TRACE is used for debugging Http Request

HTTP Status codes: HTTP Status code is part of Http response, and indicates the result of processing an HTTP request. Whether an HTTP request has been processed successfully or if there was an issue in handling Http request.

Below is list of Http status code series and purpose of it

100 to 199 — Informational response

200 to 299 — Successful response, such as 200-OK, 201-Created(i..e Resource created successfully on Server)

300 to 399 — redirect the Http request to some other URL

400 to 499 — Client side errors, such as 400-Bad Request, 401&403-not authorized to access, 404-resource doesn’t exist

500 to 599 — Server side errors, such as there was internal error in Web Server, either due to application or configuration of Webserver

Some built-in HTTP Headers:

HTTP Headers hold meta data related to Http request or response. Below are commonly used Http Headers

  1. Content Type of request/response Data(For eg. Content-Type — indicates Media Type of Request/Response body, Accept , Accept-Language),
  2. Caching related(For eg. Cache-Control, Expires, etc…)
  3. Authentication related(For eg. Authorization)
  4. Other General Http headers(For eg. Last-Modified, Cookie, Set-Cookie, Location, etc…)

Authentication Support:

HTTP has inbuilt support for below Authentication protocols

  1. Basic Authentication
  2. Digest Authentication

Some more details of HTTP:

Web Server by default listens on port 80(it’s not 8080) for HTTP. And for HTTPS 443 is default port number.

HTTP is independent of Programming Language/Framework or Operating Systems(i..e Web Client, Web Server applications developed in different Programming Languages can operate together seamlessly)

HTTP is state less protocol

REST API services can be developed using HTTP(or HTTPS) protocol only.

REST is used to develop SOA(Service Oriented Architectures), and is light weight compared to SOAP

HTTP uses TCP/IP protocol internally

--

--

Suresh Kumar

With about 23 Years of experience in Software development, currently into Corporate Training on Java Full Stack, Microservices, Angular, Design Patterns