In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
6.1introduction to HTTP
Web, servers, and related Web applications all communicate with each other through HTTP. HTTP (HyperText Transfer Protocol, Hypertext transfer Protocol) is a common language used in modern global Internet. Web content is stored on Web servers, and Web servers use the HTTP protocol, so they are often referred to as HTTP servers. These HTTP servers store data from the Internet and provide data if the HTTP client requests it. The client sends a HTTP request to the server, and the server sends back the requested data in the HTTP response.
Resources and types of resources
The Web server is the host of Web resources, and Web resources are the source of Web content. The simplest Web resource is the static file in the Web server file system. These files can contain anything: text files, HTML files, word files, AVI movie files, and so on. But resources are not necessarily static files, resources can also be software programs that generate content according to needs, and these programs can generate different content according to the identity of the user and the requested information.
There are thousands of different data types on the Internet, and HTTP labels each object to be transmitted through Web with a data format of MIME type. The Web server appends the MIME (Multipurpose Internet Mail Extension, Multipurpose Internet Mail extension) type to all HTTP object data. When a Web browser retrieves an object from the server, it looks at the relevant MIME type to see if it knows what to do with the object. Most browsers can handle hundreds of common object types.
The MIME type is a text tag that represents a major object type and a specific subtype, separated by a slash.
Text documents in HTML format are marked by the text/html type
Ordinary ASCII text documents are marked by the text/plain type
The JPEG version picture is of image/jpeg type.
The GIF version picture is of image/gif type.
...
URI and URL
Each Web server resource has a name so that the client can find the resource it needs. The server resource name is called the uniform Resource Identifier (Uniform Resource Indentifier,URI). URI, like the postal address on the Internet, uniquely identifies and locates information resources around the world.
For example: http://www.joes-hardware.com/specials/saw-blade.gif
Uniform Resource Locator (Uniform Resource Locator,URL) is the most common form of resource identifier, and URL describes the specific location of a resource on a particular server. They can specify how to obtain resources from a precise, fixed location. The figure shows how URL accurately describes a voluntary location and how to access it.
Business
The following figure shows how the client transacts with the Web server and its resources through HTTP. An HTTP transaction consists of a request (from the client to the server) and a response (the server sends back to the client). This communication takes place through the formatted data blocks of the HTTP message.
HTTP supports several different request commands, which are called HTTP methods (HTTP mothod). Each HTTP request message contains a method. These methods tell the server what action to perform, and common HTTP methods are:
When GET requests to obtain a resource, it requires the server to send HEAD similar to GET, but it does not need the service to send resources, but only sends back the response header PUT, which is opposite to GET, and writes a document to the server. For example, the publishing system DELETE requests to delete the resource OPTIONS pointed to by URL.
Probe the request method TRACE supported by the server for a resource
POS such as firewalls, agents, or gateways to track requests to go through
Support for HTML form submission, where there is data filled in by the user, which is sent to the server and stored in a location (such as a send handler)
Each HTTP response message is returned with a status code. A status code is a three-digit code that tells the client whether the request was successful or whether other actions need to be taken. Common status codes are:
1xx pure informational status code 2xx
Information for the "success" class (200,201,202) 3xx
Redirect status code
301:Moved Permanently, specify the current location of the resource with the header "Location: URL" in the response message
302:Found, using the header "Location: URL" in the response message to specify the temporary resource location
304:Not Modified, used in conditional requests; (used in caching)
4xx
Information about the client error class
403:Forbidden, request rejected by server
404:Not Found, the server cannot find the requested URL
405:Method Not Allowed, it is not allowed to request the corresponding URL using this method
5xx
Server-side error class information
500:Internal Server Error, server internal error
502:Bad Gateway, the proxy server received a pseudo response from the upstream
503:Service Unavailable, the server cannot provide service at this time, but may be available in the future
504:Gateway Timeout, when the gateway proxy requests the backend service, the backend service does not respond in time.
Message
HTTP messages are made up of simple strings on a line. Http messages are plain text, not binary code, so they can be easily read and written. The following figure shows the HTTP message used by a simple transaction.
The HTTTP message is mainly divided into three parts: the starting line, the header field and the body.
Request message syntax:
(name:value)
(must be a blank line)
Message body
Response message syntax:
(must be a blank line)
Request method, the actions you want the server to perform, such as GET, HEAD, POST, etc.
The requested resource can be either a relative path or a complete URL
Protocol version, format HTTP/., such as http/1.0
: HTTP header
Status code
Reason phrase, numeric status code readable information
: body part
HTTTP protocol version
Http/0.9: plain text only (hyperlinks), ASCII
Http/1.0: supports multimedia data processing. Staying connected is supported.
Http/1.1: persistent connections are supported. Finer cache control
HTTP-NG, also known as HTTP/2.0, focuses on significant performance optimizations and a more powerful remote execution framework for service logic, but has no plans to replace http/1.1.
HTTP header
The HTTP header works with the method to determine what the client and server can do. The first part can usually be divided into five types:
General header: both request message and response message can be used
HTTP/1.0 introduces headers that allow HTTP applications to cache local copies of objects so that they do not always need to be fetched directly from the server segment.
Request header: meaningful only in the request message
The informational header of the request:
First part of Accept:
Conditional request header:
Security request header:
Proxy request header:
Response header: meaningful only in the request message
Informational header of response
First part of negotiation
Security response header
Entity header: used to specify entity attributes
The informational header of an entity
Content header
Entity cache header
Extension header: non-standard header, which may be created by program developers, such as X-Forward-For
Implementation Software of HTTTP
Client:
GUI:IE 、 Firefox 、 Safari 、 chrome 、 Opera
CLI:elinks, curl
Server:
Server: httpd (ASF Foundation), nginx, lighttpd
App Server: IIS 、 tomcat 、 jetty 、 resin
6.2. the architectural way in which the Web server handles connection requests
1. Single-thread web server (Single-threaded web servers)
In this architecture, the web server processes one request at a time, and then reads and processes the next request. During the processing of a request, all other requests will be ignored, so there will be serious must-be problems in scenarios with more concurrent requests.
2. Multi-process / multi-thread web server
In this architecture, the web server generates multiple processes or threads to process multiple user requests in parallel, and the processes or threads can be generated on demand or in advance. Some web server applications generate a separate process or thread for each user request to respond, but once the number of concurrent requests reaches thousands, multiple processes or threads running at the same time will consume a lot of system resources.
3. Icano multiplexed web server
In order to support more concurrent user requests, more and more web servers are adopting a multi-reuse architecture-synchronously monitoring the activity status of all connection requests, and performing a series of specific operations for a connection when the state of a connection changes (such as data preparation or an error occurs) After the operation is complete, the connection will return to a temporary steady state and return to the list of open connections until the next state change. Because of its multiplexing nature, processes or threads will not be occupied by idle connections, so it can provide an efficient working mode.
4. Multiplexing multithreaded web server
The web server architecture, which combines the functions of multi-process and multiplexing, avoids making one process serve too many user requests, and can make full use of the computing power provided by multiple CPU hosts.
The process of a web request response
1. Establish a connection-accept or reject client connection requests
2. Receive the request-read the HTTP request message through the network
3. Process the request-parse the request message and take corresponding actions
4. Access resources-- access related resources in the request message
5. Build the response-use the correct header to generate the HTTP response message
6. Send response-send the generated response message to the client
7. Log-- when completed HTTP transactions are recorded in the log file
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.