HTTP Web server

Source: Internet
Author: User
Tags hosting

Web server implementation
web服务器实现了http和相关的tcp连接处理,负责管理web服务器提供的资源,以及对web服务器的配置、控制、及扩展方面的管理。
    1. There are many kinds of generic software Web servers, mostly from three companies, Apache, Microsoft and Sun IPlant.
    2. Web server devices are pre-packaged hardware and software solutions, and vendors pre-install the server on the computer platform they choose, and configure the software well.
    3. Embedded Web servers can be embedded in consumer electronics.
What the actual Web server will do
    1. Establish a connection if you do not want to establish a connection with this client, close
    2. Accept Request
    3. Processing requests
    4. Accessing resources specified in a resource access message
    5. The build response creates an HTTP message with the correct response header.
    6. Send response
    7. Record transaction processing process
Accept client Connections
客户端请求一条到服务器的tcp连接时,web服务器会建立连接,并将接连添加到现存的web服务器连接列表中去,做好监视连接上的数据。web服务器可以随意的拒绝或者关闭任意一条连接。客户端主机名识别:web服务器将客户端主机名用于**详细的访问控制和日志记录**。但是请求过来的时候,只有客户端ip,可以通过方向dns来查找主机名,但是可能会很慢。通过ident协议来确定客户端用户。如果客户端支持ident协议,就在tcp端口113上坚挺ident请求。这种方式在因特网上,并不常用。
Accept Request Message
解析请求行,获取请求方法,和资源标识符。获取首部。如果有的话,还需要读取请求主体。
    1. Intra-message representation some Web servers use internal data structures to store request messages. Place the header in a quick query table.
    2. The processing structure of the connection input and output because there are requests that will arrive at any time, the Web server will not stop observing any new Web requests. Different Web server architectures will serve requests in different ways: single-threaded Web servers, multi-threaded and multithreaded Web servers, multiplexed IO servers (asynchronous IO), and multiplexed multi-threaded Web servers.
Mapping and access to resources
负责发送预先创建好的内容,或者服务器上程序动态生成内容。
    1. Docroot's simplest resource mapping is to use the URI as the name to access files in the Web server's file system. The Web server will have a special folder dedicated to Web content. called the document root directory . Place the URI in the request behind the root directory to find the corresponding resource.
    2. The docroot of virtual hosting is to provide multiple Web sites on a single server, each with its own unique document root directory on the server. The virtual hosting Web server identifies the correct document root directory based on the host name or IP of the URI or host header.
    3. The user's home directory docroot Web server to provide people with private sites, usually the slash and wavy lines to start/~. Private docroot are usually the directory named public_html under the user's home directory.
    4. Directory list If a client requests a directory instead of a resource, it will be handled in the following ways: Returning an error, not returning a directory, returning a special default index file, scanning the directory, and returning an HTML page containing the contents of the directory. Most servers will go to the directory to find the index.html file in place of this directory. This can be configured.
    5. The dynamic Content Resource Mapping Web server can also map URIs to dynamic resources. Maps to programs that dynamically generate content on demand. The Web server can tell when a resource is dynamic and where the dynamic content generator is located. Apache allows users to map URIs to executable directories.
    6. Access control for specific resources, access control
Build response
    1. Response entity MIME type, content-length (not necessarily, if the server responds to this request, the connection is turned off without this, the entire stream, all belong to this topic), the actual content of the subject.
    2. The MIME type Web server can use the file name extension to describe the MIME type. The Web server scans each resource for a MIME type file that contains all the extension names. -Magic Category Scan content, determine mime. -Explicit classification According to directory-type negotiation
    3. Redirection applies to the following situations: permanently deleted resources (301), temporarily deleted resources (303), url enhancement (303,307), responsible for equalization, server affinity, canonical directory name.
Send response
要注意此次响应发送完之后,是否要关闭连接。

HTTP Web server

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.