One of them is, again, the GET command or the GET method.
And what that does is it says,
I want to retrieve the resource from the particular location.
And the way you pass the data using that method
is you pass it to the server as part of the URI.
As you remember, we had the query string, well, that's how you pass the data.
And the data is not so much to be stored on the server as much as really a way for
us to tell the server and identify a particular resource, or
maybe filter a particular resource, the data from that particular resource.
So we need to pass the data to the server in order to get the data back.
It's not really for the server to store it, necessarily.
The other command, or the other method, HTTP method, is POST.
And this method sends the data to the server in order to be processed.
And the data that you sent to the server is sent in the message body.
Now the server may still respond, and most of the time does,
respond with some sort of response, maybe an HTML page, maybe some sort of data.
But that data is more viewed as a status or kind of a confirmation that
the data that you sent to the server was in fact processed, whatever that means.
Stored or some other side effect happened because of it, but
it's an indication that it was processed.
Now, there's many more methods that we're not covering here,
but these are good enough just to get an idea of the actual protocol.
So when we talk about POST request and the data being sent as part of the message,
let's go ahead and quickly visualize what that looks like.
So this is a typical POST request, and
you could see there's a POST /index.html, but there's no query string.
The query string or
the data that we're passing comes as part of the body of the message.
So there's a few parts here that actually exist on pretty much every POST request,
which is the first line, the POST request itself, followed by some request headers.
In this example, Accept-Charset is telling the server that our
browser knows how to process utf-8 character set.
And, after that, we have the message body.
This is where the data is being passed to the server.
So this is the POST request.
Let's take a quick look as to what an HTTP response structure is like.
Well, it starts with just a response status line.
And the response status line has three components.
The first one is the HTTP version.
So the server spits back out the version of HTTP it's communicating.
The second is the response status code.
And the third is the English phrase describing that status code.
And all three parts are separated by a single space.
So a typical HTTP response may look something like this.
It will start with HTTP/1.1 200 OK.
It will follow by some HTTP response headers,
in this case, it will tell you what the date of this document is.
It will tell you the content type, in this case, it's text in HTML.
And then the body of the message or the body of the response will be HTML.
Now the message body of the response need not be HTML.
It can be, for example, plain text, XML, or
JSON, something we haven't really talked about yet.
So let me show you some common response status code.
One of them is 200 OK.
And that basically means that the server is saying, okay, I got your request,
and here's the content you requested.
Another one is 404 Not Found.
In this case,
the server says, I just can't find the resource that you requested.
403 Forbidden, and that means that, for whatever reason,
the server thinks that the client, your browser, is unauthenticated and
tries to access a secure resource that requires some sort of username and
password or a certificate or something like that.
And another one, pretty common, is 500 Internal Server Error, and
usually that happens when some error was raised on the server and
was unhandled on the server and it kind of spilled over.
And now, you as the user probably in the browser are seeing 500 Internal Error.