Objective
with the rapid development of the Internet and the popularity of the network, all kinds of web sites, the website has become the main way of enterprise propaganda and strength show path, when it comes to the Web site will have to say that the Internet services, and now the more popular Web services are Apache is httpd. This article will explain the HTTP protocol and HTTPD features.
HTTP protocol Detailed
HTTP protocol
Http:hyper Text Transfer Protocol Hypertext Transfer Protocol
Transfer text: HTML
Html:hyper Text Mark Language Hypertext Markup Language
How HTML documents are generated
Static: Document in plain HTML format
Dynamic: Programs written in programming languages can output HTML-formatted results
HTTP protocol version
HTTP 0.9: Only for transferring HTML documents
HTTP 1.0: Introduce a MIME mechanism to support multimedia data; introduce keep-alive (persistent connection); cache
HTTP 1.1: More request method, finer cache control; Persistent connection (persistent)
Note: The HTTP protocol is stateless
HTTP transactions: One request and the corresponding response
Cgi:common Gateway Interface Universal Gateways Interface
HTTP protocol messages
Request message
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/5F/D1/wKioL1UqYgDza24OAADWNY9iJ3M805.jpg "title=" 1.jpg " alt= "Wkiol1uqygdza24oaadwny9ij3m805.jpg"/>
Detailed message
Request messages consist primarily of request lines, request headers, and request data (entities)
① Request Line
The request line consists of the request Method field, the Request Resource field (URL), and the Protocol version field
HTTP method:
Get: Request to get a resource, requires the server to send head: with Get approximation, but it does not need the service to respond to the requested resource, and return the response header post: Based on the HTML table one-way server to submit data, Servers typically need to store this data (location: typically a relational database) PUT: Send resources to the server instead of get The server typically needs to store this resource (location: typically a file system) Delete: Delete the resource that the URL points to options: Probe server-side request method that is supported by the requested URL trace: A proxy server, firewall, or gateway that passes in the middle of a request Note: Methods are strictly case-sensitive
Resource Name: URI (Uniform Resource idnentifier)
URL: Describes a specific location for a resource on a specific server
Can be a relative path, or an absolute path for example: Http://www.scholar.com/download/index.html is divided into three parts: scheme (Scheme): http://server, www.scholar.com Resources on a specific server:/download/index.html
Protocol version: For example http/1.0, http/1.1
② Request Header
HTTP protocol Header:
General Header
Connection: Defines the relevant options for request and response between C/S Connection:keep-alivecache-control: Cache control via: Shows the intermediate node through which the message passed
Request Header
CLIENT-IP: Client iphost: Requested host Referer: Indicates the urluser-agent of the original resource that requested the current resource: User Agent Accept Header: Accept: Indicates the type of media that the server can send accept-charset: Supported character sets Accept-encoding: Supported encoding method Accept-language: Support for language conditional requests: Expect: Tells the server which media types to send if-modified-since: Has this resource been modified in the specified time If-none-match: If the provided entity tag does not match the entity tag of the current document, obtain this document with security-related requests: Authorization: Authentication data that the client submits to the server, such as account number and password cookie: The client sends the identity to the server
Entity Header
Location: The new position of the resource allow: the header that allows the content of the request method to be used for this resource: content-encoding: Support encoding Content-language: Support for language content-length: Text length content-location: Resource Location Content-type: Principal Object Type Content-range: The byte range cache associated with this entity represented in the entire resource: ETAG: Entity label Expires: Expiration period Last-modified: Last modified time
③ entity
The entity contains data for the client Pull server
Response message
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/5F/D5/wKiom1UqYM3BhcK7AADUQD-8OyA244.jpg "title=" 2.jpg " alt= "Wkiom1uqym3bhck7aaduqd-8oya244.jpg"/>
Detailed message
Response messages consist primarily of status lines, response headers, and response data (entities)
① status Line
The status line consists of the Protocol version field, the Status Code field, and the reason phrase field
Status code:
1xx: Informational Status Code 2XX: Success Status code      200:OK, client request success 201:created, the request has been implemented 3xx: the status code of the redirect class 301: moved Permanently, permanent redirection 302: Found, temporary redirection, using "Location:" In response messages New Location " 304: not modified, using 4XX in conditional requests: Client class error 403:forbidden, the request was rejected by the server 404: not found, the server could not find the requested url 405: method not allowed, it is not allowed to request the appropriate url5xx using this method: Error of server class 500:Internal Server Error, Server Internal Error 502:bad gateway, Proxy server receives a pseudo response from the upstream server 503:Service Unavailable, service is temporarily unavailable 505:http version not supported, the server does not support
② Response Head
Response header
Date: The time the message was generated Age: Response Duration server: Describe your program name and version to the client etage: Opaque authenticator location:url Alternate location content-length: Length of entity content-tyep: Media type negotiation header for entity: ary: Header list, The server picks the most appropriate version from the list to send to the client accept-ranges: for the current resource, the type of scope that the server can accept is security-related: www-authentication: Challenge, Customer is required to provide account number and password Set-cookie: The server side sends a token on the first request of a client
③ entity
The entity contains the data requested by the client, packaging the data requested by the client according to the request data in the parsing request packet, The message is sent to the client, and if the request has an error, the error code and the reason within the message are displayed.
Resource request process and server structure
The exact process of a Web resource request (server perspective):
Establish a connection receive request processing Request Access resource build response Send response log
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/5F/D6/wKiom1UqYPOyraEQAAFDumCoUBw407.jpg "title=" 3.png " alt= "Wkiom1uqypoyraeqaafdumcoubw407.jpg"/>
I/O structure of the Web server:
Single Process model: serial
Multi-process Model: Each process responds to a user request for concurrent results
Multiplexing I/O mechanism: One process generates multiple threads, and each thread responds to a user request
Multiplexing I/O Mechanisms: Multiple threads, each responding to multiple user requests;
HTTPD Features
HTTPD characteristics
Highly modular: Core + modules
Dso:dynamic Shared Object
Mpm:multipath processing Module
MPM contains: prefork: Each process responds to a user request, pre-generates multiple idle processes, worker: Starts multiple processes, each process generates multiple threads, each thread responds to a user request, event: Starts multiple threads, each thread responds to n requests;
httpd Functional characteristics
Rich user authentication: Basic Certification and Digest certification
CGI: Native support for Perl CGI
Virtual Host: Based on port, IP, host name
Reverse Proxy: Load Balancing
User sites: Users can create sites at home directory
Path alias: Alias
Support for third-party modules
The end
Well, the HTTP protocol and the HTTPD feature are here. Below will explain the virtual host and based on user access control and SSL implementation of HTTPS and other configuration, interested can continue to follow yo. The above is only for individual learning to organize, if there are mistakes, big God do not spray ~ ~ ~
This article is from the "North Scholar" blog, please make sure to keep this source http://scholar.blog.51cto.com/9985645/1631602
HTTP protocol and HTTPD features detailed