Today, let's talk about the request-response cycle or
basically what happens when you type something into the address bar of your browser.
One of the things I think is really funny and I'm guilty of it as well,
is that we all do things and we have no idea how they work.
So, if I were to ask you when you type in an address, what happens?
So, this lecture is actually one of the most technical of this entire class.
I don't want to feel like you need to memorize this or write it down,
but I do think it will help you understand a little bit
more what's going on as you learn HTML5.
So, one of the things you might want to understand is the client-server relationship.
Servers are basically machines that hold all the resources.
Our hope is that they're always connected to the network.
Clients are what we're using,
where the machines that you use for personal use;
like laptops, phones, et cetera.
Let me show you in this picture.
It's really common to use networks such as something called a LAN or a WAN.
A LAN is a local area network,
and so what I have right here is this idea that we can have
three different computers and they're all sharing one server.
لماذا نريد أن نفعل ذلك؟
Well, a lot of times,
you only have one printer or one of the different resources.
This way, all three machines can work together and share that one resource.
So, the LAN is the local area network.
Sometimes, you want to have something larger or a wide area network.
So, in movies, where the good guy is breaking into the building to steal the software,
what's typically happened is they have this server that
everyone who works in the building can access but no one outside the building,
or you can even have it across different buildings but you don't
want anyone from the outside to really be able to get your information.
So, local area network is like your office building.
A wide area network might be a university,
where you want to be able to share servers across multiple buildings.
The largest wide area network is, of course, the Internet.
So, now we get back to that question of
what happens when you type something into the URL?
What you're doing is that you the client are requesting
a web page and the server needs to respond with the appropriate files.
So, when you type something in,
this is called the URL.
Every URL has three parts.
The protocol, how you want to connect, the domain,
which is the server,
and then optionally, you can include the document.
So, even though you're typing in one URL,
one of the things to realize is that usually,
you're actually requesting lots and lots of files all at once.
So, the protocols that most people have seen;
the first one is HTTP,
the Hypertext Transfer Protocol.
The second one, HTTPS,
is the same idea,
only now we're having a more secure protocol.
So, if you're ever connecting to a bank or any place where you're putting in passwords,
make sure that the first thing you see in that URL is HTTPS.
If you don't, don't connect.
The third one is called the File Transfer Protocol.
إنه مختلف قليلاً
When you see HTTP,
it's expecting that you're going to give back and forth HTML5 code;
with FTP, it could be any type of file.
So, we have the protocol,
now let's talk about what the domain names represent.
Usually, the domain names are something recognizable, such as umich.edu,
would be for University of Michigan.
Google.com, wikipedia.org.
So, each of these sites has a different top-level domain.
How did you get them?
How do some people get to be.edu and some.com, some.biz, et cetera?
Well, they're actually determined by ICANN.
Their job is to go in and decide which types of
organizations qualify for different domains.
I've included a link here if you want,
you can go and see what the different types are.
But the important thing to know is that
your domain name is actually mapped to an address.
In the old days, like when my Dad was on the Internet,
if he want to connect to some place,
he would actually type in numbers;
185.261 et cetera, et cetera.
Well, there's been a new version of IP addresses,
because every single client needs their own address.
If you think of how many people have laptops and smartphones,
we need a lot of different options.
So, with these IP addresses,
you basically have sets of numbers,
you have these different sets right here,
where each X can represent one of 16 different values.
So, you can see we have a lot of options,
over 300 trillion, in fact.
As I said, luckily for you,
the domain name server lets you type in something really simple like Umich or Google,
and it's the one that turns it into that really long number.
The last part of your URL is the document.
So, sometimes you want to specify a very specific document that you want to get.
So, for instance, the contact page,
or in this case,
another one I have the file that's inside a folder.
But sometimes you don't put a document at all.
In fact, most of the time, you don't.
If you type in wikipedia.org or Facebook.com,
there's no filename. But that's okay.
Every server has a default document that it's going to return.
Usually, it's called index.HTML.
All right. So, we figured it out.
We know what it means when we're typing something in.
We understand the request.
What happens though once we type that in,
is we are actually going to get back a lot of information.
Headers, cookies, form data,
all the stuff that you don't see.
So, the important thing to know is that the server returns files, not web pages.
For a lot of us, we are very visual.
So, when we type in a URL,
we're looking and we're like,
"Oh, here's my page."
But sometimes the browser might be returning
something for different types of screen readers,
assistive technology, so it's not returning a web page,
it's returning lots and lots of files.
Hopefully, I will admit that sometimes the server can't fulfill the request.
If it can't, it'll send back an error code.
I think a lot of you are familiar with 404,
where it says, "File not found."
That usually means you typed something in wrong.
If you get a 500 error,
that actually means that the servers down.
So, you may as well go have a snack,
do something fun, come back later and type it in again.
So, I want to do a live demo with you of what happens when we type something in.
So, I've written it down for you.
It looks up the domain,
the DNS returns an IP address,
and then a whole bunch of files start to be returned. Let's take a look.
What I've done here is I've gone to the school of
information site at the University of Michigan.
I simply typed in si.umich.edu.
I didn't type in the protocol because it usually just defaults.
So, what you see here visually is a page.
Student looking out, looking very inspired, et cetera.
But now, I'm going to do a little trick here,
where I right-click on the screen,
and I'm going to choose the option that says, "Inspect."
A window's going to pop up to the side here.
I'm going to say, "You know what?
I would like to see all the information that's
being returned when I actually request this page."
I'm requesting one page, I'm going to hit "Refresh."
If you look off to the side,
don't worry that you can't see the details.
But you should see that the single page is actually made up of lots and lots of files,
and each one of these files was a separate request.
Okay. So, let's review.
This was a long video,
where really all I want you to come away from it with is
the knowledge that every URL has those three parts;
the protocol, the domain, and the document.
Realize that what you're creating is bigger than just one file at a time.
Every request-response cycle is usually lots and
lots of rounds of communication between the client and the server.
So, we're going to start off small.
We're going to do one file at a time,
but you can always look ahead to building bigger and bigger web applications.