So most every day, you probably type or
at least see HTTP.
In fact, if you're watching or listening to this over the
web, you're using HTTP right now.
But what is it?
Well, it's what you type at the start of a URL, or at
least used to.
These days, browsers just assume that you want HTTP,
even if you don't actually type it.
More technically though, HTTP is a protocol, a language of
sorts, that web browsers and web servers speak, a set of
conventions to which they adhere, just
like we humans have.
For instance, in the US, when you first meet someone, you
typically initiate a connection by extending your
hand, at which point, the other person responds to it by
shaking it.
Well, that's a protocol.
In some countries or families, you initiate a connection by
kissing someone on the cheek.
Well, that another protocol.
So HTTP is a protocol that happens to involve computers
instead of humans.
And here's how it works.
When a browser wants to show a human a web page, it initiates
a connection to a web server by sending an HTTP request,
inside of which is a message akin to please
send me this web page.
In reality, it's something more cryptic like,
get/http/1.1.
But when the server receives that request, it sends an HTTP
response, inside of which is the web page.
Now that web page, meanwhile, is written in a language
called HTML, or HyperText Markup Language.
And that's HTTP gets its own name.
HTTP is an acronym for HyperText Transfer Protocol,
because what it's transferring from server to browser is
hypertext, HyperText Markup Language.
In a sense, the web is like a restaurants where you're the
customer or the client.
Much like you order food in a restaurant from a waiter or
waitress who then brings it to your table, so do web browsers
order files from a web server who then
returns with the same.
In fact, is for this very reason that browsers are often
called clients and servers are called, well servers.
The relationship is very much the same.
Make sense?
All right, well let's take a look at an actual HTTP request
and response.
First, let's open a browser.
I happen to be using Chrome, but you do this in most any
browser these days.
Let's next select View, Developer, Developer Tools,
which will open a Developer panel at the
bottom of our window.
And let's next click that panel's Network tab.
The next time I load web page from a server, we'll see in
this tab all of the HTTP traffic between
Chrome and the server.
OK.
Let's visit, say, Google.
http://www.google.com/enter.
OK, what just happened?
Well first, let's scroll to the very top of the tab.
The very first row represents Google's HTTP response to my
HTTP request.
Well, let's click that row.
To the right, we now see a preview of the HTML that was
included in that response, along with a whole bunch of
JavaScript.
But more on those another time.
Let's now click the Headers tab to the left of this
Preview tab, and here's where we can see the actual HTTP
request that my browser sent and the actual HTTP response
that Google returned.
As for the server's response, let's click View Source next
Response Headers.
Here's what Google sent to my browser.
The first line is perhaps the most interesting--
HTTP/1.1 200 OK.
This means all is well and the homepage was transferred
successfully.
Odds are you've never seen this 200 before, otherwise
known as an HTTP status code, but you've probably seen 404,
File Not Found, maybe some others.
Well, this is where those numbers come from.
Well there you have it--
HTTP.