- Read Tutorial
Did you ever wonder what the http://
stood for in the browser? It's actually something pretty important when learning how to build APIs and microservices. HTTP stands for:
HyperText
Transfer
Protocol
Makes perfect sense, right? Well it wasn't for me right away so let's start walking through it from a high level perspective.
When you go to google and type in funny cats
that initiates an HTTP request that is directed to google's servers. After finding the correct results on the server, google sends back a list of links via an HTTP response and those are rendered in the browser. Essentially, the majority of interactions you make on a website initiate http requests and send back http responses.
While the concept of HTTP transfer is a complex topic that hundreds of books have been written about, if it's new to you, first understand the ideas of requests and responses since that is what we'll be using throughout this course.
HTTP Requests
Requests are what you send to the server. This typically will include parameters, such as funny cats
. It can also include data such as information submitted on a form for creating records in a database, a username/password, and pretty much everything that users send to servers.
In addition to the parameters that the users are aware that they're sending, HTTP requests also include metadata, such as session information. For example, the request can let the server know that the user is signed in or that the user is a guest. Requests can also carry security parameters, for example Rails utilizes a hash function to ensure that form data isn't being sent from malicious hackers.
HTTP Responses
The response data is what the server sends back based on the request. For example if you go to a blog index
page it the server will send back an HTTP response that includes all of the posts
. In addition to content that will be rendered in the browser, the response also includes status codes so the client (the client can be the browser or an application communicating with the server) will know what type of response is being sent back. Below is a high level list of HTTP status codes:
- 1xx Informational
- 2xx Success - this means everything worked according to plan
- 3xx Redirection - this means no error was thrown, but the resource has moved
- 4xx Client Error - this means a problem happened, such as a page not existing
- 5xx Server Error - this means the server is having issues
Here is the full list of status codes and explanations for each of them.