Communication Networks/HTTP Protocol
From Wikibooks, the open-content textbooks collection
Contents |
[edit] HTTP
The Hypertext Transport Protocol (HTTP) is an application layer protocol that transmits text over the internet. HTTP stands for (Hyper-Text Transfer Protocol). HTTP is based on the TCP/IP protocols, and is used commonly on the internet for transmitting webpages from servers to browsers.
[edit] What is HTTP
Applications that use HTTP protocol to send and receive text documents are called "Web browsers", and there is a good chance that you are reading this page using a web browser that uses HTTP protocol.
HTTP protocol uses TCP protocol to create an established, reliable connection between the client (the web browser) and the server (wikibooks.org). All HTTP commands are in plain text, and almost all HTTP requests are sent using TCP port 80, of course any port can be used. HTTP protocol asks that each request be in IP address form, not DNS format. So if we want to load www.wikibooks.org, we need to first resolve the wikibooks.org IP address from a DNS server, and then send out that request. Let's say (and this is impossible) that the IP address for wikibooks.org is 192.168.1.1. Then, to load this very page, we would create a TCP packet with the following text:
GET 192.168.1.1/wiki/Communication_Systems/HTTP_Protocol HTTP/1.1
The first part of the request, the word "GET", is our HTTP command. The middle part of the request is the URL (Universal Resource Locator) of the page we want to load, and the last part of the request ("HTTP/1.1") tells the server which version of HTTP the request is going to use.
When the server gets the request, it will reply with a status code, that is defined in the HTTP standard. For instance:
HTTP/1.1 200 OK
or the infamous
HTTP/1.1 404 Not Found
The first part of the reply is the version of HTTP being used, the second part of the reply is the error code number, and the last part of the reply is the message in plain, human-readable text.
[edit] HTTP Methods
[edit] HTTP Status Codes
[edit] HTTP Success Codes
2** Success
200 OK
[edit] HTTP Error Codes
4** Client Error
403 Forbidden
404 NOT FOUND
5** Server Error
500 INTERNAL ERROR