Let us learn/understand the essentials and basic concepts of HTTP (HyperText Transfer Protocol)
This tutorial, reference/learning material is for beginners who do not have any understandings about HTTP. Here will cover the fundamental concepts of HTTP.
Add topics to categorize your repository and make it more discoverable:
- http
- hypertext-transfer-protocol
- web-server
- webserver
- client
- client-server
- http2
- http-methods
- get-post-put-delete-methods
- http-vs-https
- https
- protocols
- request-response
- ip-tcp
- http-responce-code
- 200-400-500
- stateless
- http-communication-request-response
- protocols-ip-tcpip-smtc-http-ftp
- http-architecture-mechanism
Hi All, I'm Dinanath Jayaswal, Senior UI/Web Developer and Adobe Certified Expert Professional
, I wanna welcome you to the Quick Introduction to HTTP
.
Welcome to the new tutorial on HTTP (HyperText Transfer Protocol).
In this introductory HTTP module will have a look and learn:
- What is HTTP
- HTTP Communication - Request & Response
- HTTP Methods
- Status Code
This Course/Tutorial is ideal for:
- Freshers
- Intermediates
- Beginner Programmers
- Any Developer/Designer
- Web Designers and Developers, Front-End/UI Designers and Developers
After completing/attending/finishing this Course/Tutorial, participants should be able to:
- Understand HTTP basics/fundamentals
- HTML5
- CSS3
- JavaScript
- Basics of any programming language
- Basic web development knowledge is useful but not required
- Introduction to HTTP
- 1.1. What is HTTP
- 1.2. Protocol
- 1.3. HTTP communication
- 1.4. HTTP communication - Request
- 1.5. HTTP communication - Response
- 1.6. HTTP Methods
- 1.7. HTTP vs HTTPS
- 1.8. HTTP Status Codes
- 1.9. HTTP/2
- HTTP Resources
> As soon as User opens `Web Browser and enter URL`, the user is indirectly making use of HTTP.
HTTP mechanism sends/transfer/transit `REQUEST` to the webserver and fetches the `RESPONSE`/data from the webserver
- HTTP stands for
HyperText Transfer Protocol
- HTTP is a
set of rules and regulations ie. principles to accomplish Internet Communication/Data Transfer
related tasks on the web (between Servers an Clients) - Responsible for
communication between Clients and Web Servers
- HTTP is child protocol of TCP/IP
- HTTP is
stateless ie. every request is completely independent
(each request is a single transaction, does not remember or dependent on past/before request) - HyperText Transfer Protocol (Internet Communication/Data Transfer on the web). A set of rules (and a format) for data being transferred on the web in the form of HTML, image, audio, video, zip, etc.
- HTTP foundation of data communication for the World Wide Web/internet since 1990. HTTP is a generic and stateless protocol that can be used for other purposes as well as using extensions of its request methods, error codes, and headers
> Every time we open a browser - visit and load pages, Submit Form, Button click for Ajax calls, ultimately HTTP REQUEST & RESPONSE mechanism used
- Hyper Text
- Looks like a normal text but have some special effects/formattings
- HyperText simply means
"Text within Text"
. A text has a link within it, is a hypertext. HyperText is a way to link two or more web pages (HTML documents) with each other - Hypertext refers to how
Web pages (HTML documents) are linked together
. Thus, the link available on a webpage is called Hypertext - Structured Text with links to other parts of a text, usually a web page
- Usually defined using an HTML - in combination with other web technologies like CSS, JavaScript, etc.
A set of rules/standards, two sides (client and server) agree on to use when communicating
- Both, the Client and Server are programmed to understand and use that particular set of rules (Its similar to two people from different countries agreeing on the same language to speak in)
Protocol | Description / Details |
---|---|
IP |
Internet Protocol |
TCP |
Transmission Control Protocol |
HTTP |
Hyper Text Transfer Protocol (Internet Communication/Data Transfer on the web) |
FTP |
File Transfer Protocol (Files) |
SMTP |
Simple Mail Transfer Protocol (Email) |
HTTP Communication in brief:
Client
Clients are often browsers (Chrome, Edge, Safari), but they can be any type of program or device
- Sends request (Request message)
- Waits for service to respond
- Once receives the reply from the server, displays results at client location/device
Web Server
Servers are most often computers in the cloud
(Continuously listens for requests)
- Accepts request send by client and redirects to a specific web site or web app
- Web site processes data
- The web server receives a reply from a web site and forwards it to the client (Response message)
Image 1.3 - HTTP Client Server Architecture
Request Message (sent from client to server) usually consists/contains the following things:
- URL
- Request headers
- HTTP request method
- Content/data
- URL
- Contains domain/path to page
- Query string/parameters to page URL (
domain-path/page=loging or so...
)
- Request headers
- Contains Browser information (current Browswer, OS, Date & Time)
- Cookies if available (User Details)
- Authentication information (User ID, Password)
- Other request information
- HTTP request method
- GET (Request/Retrieve/Get Data)
- POST (Send Data)
- PUT
- DELETE
- Content/data
- Sent during POST/PUT Request body
Response Message (sent from server to client) usually consists/contains the following things:
- Response headers
- Content/data
- Response headers
- Contains HTTP response code (200, 400, 404 and so on)
- Cookies if available (User Details)
- Content-type, size (file type - HTML, image, zip with file size in the form of bytes sent from server to client)
- Content/data
- The result from the server (HTML) as a Response body
> Open any web page
-> Inspect Element (Developer Tool)
-> Network Tab
-> check **Headers**, **Preview** and **Response** Tab information / details
Here the main or widely used HTTP methods:
- GET
- POST
- PUT
- DELETE
- GET (Retrieve)
- Retrieves data from the server
- POST (Create)
- Submit data to the server
- PUT (Update)
- Update/Modify data already on the server
- DELETE (Delete)
- Delete data from the server
HTTPS:
HyperText Transfer Protocol Secure
- Data sent is encrypted
- HTTPS (HTTP over SSL or HTTP Secure) is the use of Secure Sockets Layer (SSL) or Transport Layer Security (TLS) as a sublayer under regular HTTP application layering
- HTTPS encrypts and decrypts user HTTP page requests as well as the pages that are returned by the Web server. The use of HTTPS protects against
eavesdropping and Man-in-the-Middle (MitM)
attacks - HTTPS was developed by
Netscape
.
In response to HTTP requests, servers often issue response codes, indicating the request is being processed, that there was an error in the request or that the request is being redirected. They are between the range of 100 to 500.
Status Code Range | Description / Details |
---|---|
1xx |
Informational Request received / processing |
2xx |
Success Successfully Received, understood and accepted |
3xx |
Redirect Further action must be taken / redirect |
4xx |
Client Error Request does not have what it needs (something is missing in the request, wrong data passed ) |
5xx |
Server Error Server failed to fulfil an apparent valid request |
Common response codes include:
Status Code | Description / Details |
---|---|
200 |
OK The request such as GET or POST, worked and is being acted upon |
201 |
OK Created |
300 |
Moved Permanently This response code means that the URI of the requested resource has been changed permanently |
301 |
Moved to the new URL |
304 |
Not modified (cached version) |
400 |
Bad request |
401 |
Unauthorized The client ie. the user requesting the server has not been authenticated |
403 |
Forbidden The client's identity is known but has not been given access authorization |
404 |
Not Found This is the most frequent and most recognized error code. It means that the URL is nor recognized or the resource at the location does not exist |
500 |
Internal Server Error The server has encountered a situation it doesn't know how to handle |
- Major revision of HTTP ver 1.0
- Many improvements are done under the hood in HTTP ver 1.0
- Responds with more data
- Reduce latency by enabling full REQUEST and RESPONSE multiplexing (One-shot response for similar resources)
- Fast, efficient, more reliable, Secure and Safe
Reference: https://developer.mozilla.org/en-US/docs/Web/HTTP/Overview
Reference: https://www.tutorialspoint.com/http/http_overview.htm