DEV Community

Cover image for HTTP Fundamentals
Anubhav Singhal
Anubhav Singhal

Posted on

HTTP Fundamentals

I have been working as a golang backend engineer for about a year now, have been playing with HTTP response and requests on daily basis. Understanding HTTP is the core of application development, and every developer should be crystal clear with them.

Recently, I came through an interesting session on HTTP at Crio: Learn by Doing and am sharing its notes with DevCommunity. Let's get it started!


What is HTTP?

HTTP stands for HyperText Transfer Protocol. It is, like the name suggests, a set of rules for querying the web.

As we humans communicate with each other through a common language following a set of grammatical rules. On the web, clients and servers communicate through requests and responses, that follow a set of rules called HTTP.

The client makes an HTTP request that contains methods, headers, body, etc., and when the server receives that request, it responds to the client with an HTTP response that contains status, headers, body, etc.


HTTP Methods

Like our language has different kinds of statements(Interrogative, Informative, Imperative, etc.), there are several types of HTTP methods of clients requests with specific roles. Some of the most important methods are:

  • GET
  • POST
  • PUT
  • DELETE

GET

GET methods are the HTTP requests which a client makes to a server for getting resources from the server. For e.g., whenever you open Google in your browser, it makes a GET request to google's server.

POST

POST methods are the HTTP requests which a client makes for sending new data to a server. For e.g. when you add a tweet, your application makes a POST request to twitter's server.

PUT

PUT methods are almost like POST methods, instead of adding information to a server, they are intended to update existing information on the server. For e.g. when you change your profile pic on Twitter, your application makes a PUT request to the server.

DELETE

DELETE methods are the HTTP requests which a client makes to delete the existing data from the server. For e.g. whenever you delete a tweet on Twitter, your application makes a DELETE request to the server.

There are more HTTP methods, but we'll limit our discussion till here only. Click here to learn more.


HTTP status codes

HTTP Status codes are part of the HTTP Response. It helps the client understand what happened to the request. It's a 3 digit numeric code(like 404, 502), which has an appropriate definition in HTTP bias, a reason phrase is also returned along with it. For eg. 404: Page not found!

There are 5 types of HTTP status codes based on the starting digit:

  • 1xx: Information Responses
  • 2xx: Successful Responses
  • 3xx: Redirect Responses
  • 4xx: Client Errors
  • 5xx: Server Errors

check more about various status codes here .


How to make an HTTP request?

Instead of your browser, there are several other ways to make HTTP requests and accept responses from servers, these are incredibly useful for developers to test their applications before deploying. We'll look into 2 most popular way of making HTTP requests:

  • Using CLI
  • Using GUI

Making HTTP requests with CLI

cURL is like a web-browser, but for the command line. Use this link to download and install cURL in your machine. You can follow this tutorial to understand how to use cURL commands to make HTTP requests.

Making HTTP requests with GUI

There are various software that are available for making HTTP requests, either of them can be used. Postman is one of the most famous apps for it, you can install it on your machine using this link.




I hope you have a good understanding of HTTP basics now. If this article helped you, support it, and share it among your peers.

Connect with me: LinkedIn | Twitter | GitHub

Happy Coding!

Top comments (24)

Collapse
 
__akash__19 profile image
Akash bhandwalkar

Informative with simple explanation. very well done Anubhav.

Collapse
 
anubhavitis profile image
Anubhav Singhal

Am glad you liked it.
Thank you!

Collapse
 
lukapavicic profile image
Luka Pavičić

Great article! I have a friend who wants to start web dev and this will definitely get him going.

Collapse
 
anubhavitis profile image
Anubhav Singhal

Thanks, Am glad you found it useful.

Collapse
 
jcapellanvasquez profile image
jcapellanvasquez

Great and very clear, it's perfect for beginners

Collapse
 
anubhavitis profile image
Anubhav Singhal

Thanks, am glad you liked it.

Collapse
 
pritkalariya profile image
👨‍💻pritkalariya

Loved how you kept it very easy to understand as well as on point 💯
Great job!

Collapse
 
anubhavitis profile image
Anubhav Singhal

Thanks, brother!
Am glad you liked it.

Collapse
 
mohsenabn78 profile image
mohsen

Thanks, this article is very good

Collapse
 
anubhavitis profile image
Anubhav Singhal

Glad to hear that, Mohsen!

Collapse
 
kmistele profile image
Kyle Mistele

This is great, especially for newbies - you did an excellent job condensing lots of information into an easily digestible format.

Collapse
 
anubhavitis profile image
Anubhav Singhal

Thanks for encouraging, Kyle.
Another article is on its way.

Collapse
 
akshayvarshney6 profile image
Akshay Varshney

Awesome Article Anubhav!!

Collapse
 
anubhavitis profile image
Anubhav Singhal

Thanks, Akshay
Am glad you liked it.

Collapse
 
geekquad profile image
Aditya Kumar Gupta

Amazing article!

Collapse
 
anubhavitis profile image
Anubhav Singhal

Thanks, Aditya.
Am glad you liked it.

Collapse
 
error404sp profile image
Shreyasi Patil

Super awesome article Anubhav! Today I learnt something new from this article 😃

Collapse
 
anubhavitis profile image
Anubhav Singhal

Thanks, Shreyasi
Am glad you found it useful.

Collapse
 
carolinahv profile image
Carolina Hernández V.

The article is great, I will investigate more on the subject ... thank you very much

Collapse
 
anubhavitis profile image
Anubhav Singhal

Thanks a lot, Carolina
I am glad it helped you.

Collapse
 
nirbhayvashisht profile image
Nirbhay Vashisht

Great job!

Collapse
 
anubhavitis profile image
Anubhav Singhal

Thanks a lot.
Really appreciate your support.

Collapse
 
reapedjuggler profile image
reapedjuggler

Great Read indeed !

Collapse
 
anubhavitis profile image
Anubhav Singhal

Thanks, glad to hear that.