The interaction of all members of the web-based is based on the use of the HyperText Transfer Protocol (HTTP). HTTP is an application layer protocol in the TCP/IP protocol stack. The current version of this protocol is HTTP/1.1. By default, port 80 is used.
With the HTTP protocol, web servers and browsers exchange information, so web servers are also often referred to as HTTP servers, and web browsers are HTTP clients. However, HTTP clients can be not only browsers, but also any programs that can use the HTTP protocol (proxy servers, search agents, etc.). An example of the interaction between a web browser and a web-browser using the HTTP protocol is shown in Fig. 1.3.
Fig. 1.3. Interaction between the browser and the server using the HTTP protocol
The HTTP protocol uses the "request-response" principle, which means that the HTTP client program sends a message (command) of the form "HTTP request" to the HTTP server; (request), and the server returns a message of the form HTTP response (response).
The HTTP request has the following structure:
METHOD/resource-name [? query parameters] HTTP/version-number Header-1 name: value Header-2 name: value
[request body that may be missing]
The first line of the query consists of three zeros:
• the first field - METHOD - corresponds to one of the supported query methods (for example, GET or POST);
• The second field -/resource-name - corresponds to the portion of the URL that sets the path to the requested resource on the web server;
• The third field - the version number - corresponds to the version of the HTTP protocol that the client is using (currently 1.0 or 1.1).
After the first query line, a list of HTTP headers is written followed by an empty string (the characters "carriage return and line completion", "rp", codes 13 and 10) that separates the request headers from the request body . After it, there may be (although not necessarily) the body of the request followed by another empty string indicating the end of the request.
For example, if the requested URL-address is mywebsite.ru/~ivanov/defaut.html, then a simplified version of the HTTP request is shown below, which will be passed to a website registered in the DNS-system with the name mywebsite.ru:
GET /~vanov/defaut.html HTTP/1.1 Host: mywebsite.ru
When using the GET method, there is no body in the message, so the query simply ends with an empty string. We will note the presence of the Host header, which specifies the domain name of the web site used.
When receiving such a request, the server will generate an HTTP response that has the following structure:
HTTP/version-number code-state text-explanatory
Header-1 name: value
The first line of the response (the status line) contains the version of the HTTP protocol followed by a status code consisting of 3 digits and a short text explanation. Below is an example of an HTTP response that can form and send a server if the requested file exists, and the person who requests it has the right to access it.
HTTP/1.1 200 OK Content-Type: text/html Content-Length: 9934
& lt; HTML & gt;
& lt; HEAD & gt;
& lt; TITLE & gt; Home page & lt;/TITLE & gt;
& lt;/HEAD & gt;
& lt; BODY & gt;
& lt; H2 align = center & gt; Welcome to the Ivanova IP website & lt;/H2 & gt;
& lt;/BODY & gt;
& lt;/HTML & gt;
Since the HTTP request passed in this example was successfully processed, the status line contains the code 200 and its short explanation is OK. Note that the HTTP response includes two lines of headers followed by an empty line followed by the content of the requested file (the body of the response).
The process of sending requests and responses between browsers and servers is not always so simple. For example, an HTML page can
contain links to other available resources that are associated with it (images, scripts, styles, etc.). Clients that perform image rendering, execute scripts, or use styles to represent pages should parse the resulting HTML page to determine what additional resources are required to properly display this page, and then generate new HTTP requests for these additional resources.
Also We Can Offer!
- Argumentative essay
- Best college essays
- Buy custom essays online
- Buy essay online
- Cheap essay
- Cheap essay writing service
- Cheap writing service
- College essay
- College essay introduction
- College essay writing service
- Compare and contrast essay
- Custom essay
- Custom essay writing service
- Custom essays writing services
- Death penalty essay
- Do my essay
- Essay about love
- Essay about yourself
- Essay help
- Essay writing help
- Essay writing service reviews
- Essays online
- Fast food essay
- George orwell essays
- Human rights essay
- Narrative essay
- Pay to write essay
- Personal essay for college
- Personal narrative essay
- Persuasive writing
- Write my essay
- Write my essay for me cheap
- Writing a scholarship essay