The working mechanism of No1_web

Source: Internet
Author: User

1. the difference between C/S structure and b/S structure

A, the hardware environment aspect. C/S structure is built on the basis of a local area network, and b/S The structure is built on the basis of the WAN.

b, the software reusability aspect. C/S software reusability of the program is not b/S software reuse in the program is good.

C, system maintenance aspects. C/S The system upgrade of the structure is difficult and must be considered as a whole, it may be necessary to re-implement a system to achieve the upgrade. b/S structure can only replace the individual construction, to achieve seamless system upgrade, reduce the cost of system maintenance, upgrade simple.

D, user interface aspects. b/S The structure uses the browser as the display interface, so there is a richer way to behave, and C/S The method of structural representation is limited.

E, dealing with problems. C/S The structure is related to the operating system, b/S The structure can be oriented to different user groups, which can be dispersed geographically and have less relationship with the operating system platform.

2. Parsing HTTP protocol requests

(1), Request line

The request line consists of only three content: The method, the URI of the request resource, and the HTTP version, which can be expressed in the following format:

Method Request-uri http-version CRLF

whereCRLF represents a carriage return and a newline.

Methods are get,POST , etc.

(2), request header

The common request headers are Accept and user-agent. Accept is used to specify the type of information that the client accepts.

For example:Accept:text/html

Accept:image/gif

Indicates that the client can receive images and HTML files or text files

User-agent is used to inform the server about the client information that sends the request, such as the client's operating system name and version information, browser name, and version information.

Other common request headers are described below:

Accept: Specifies the type of information supported by the client.

Accept-charset: Specifies the set of characters that the client can accept, such as iso-8859-1,GB2312 , and so on. If this field is not set, it means that any character set can be received.

Accept-encoding: Specifies an acceptable encoding for the client.

Accept-language: Specifies the natural language that the client can accept, and if the domain is not set, the client can accept various languages.

Host: Specifies the hosts and port numbers on which the requested resource resides, with a default port number of.

Connection: Specifies whether to maintain or close the connection after the request has ended.

Examples of HTTP requests:

Get/index.html http/1.1

Accept:text/plain/* plain ASCII text file * /

accept:text/html/*html text file * /

user-agent:mozilla/4.5 (WinNT)/* Specify User agent * /

/* Empty line * /

It is important to note that the HTTP request using the GET method cannot contain entity content, while using POST,PUT , and The DELETE method can contain entity content in an HTTP request.

(3),GET method and POST method

there is a limit to the total number of characters in the Get method, which depends on the specific server. If the text that the user types in the address bar is too long, the get method may not work correctly.

The data sent with the Get method is appended to the URL and is displayed in the browser's address bar, so some of the more private or sensitive data is not recommended to use get method to send.

In the GET method, the parameter is appended to the request URL , with a "?" Beginning. Use "&" between the parameters to separate each parameter.

Examples of sending data using the POST method are:

post/index.html HTTP1.1/* Request Line * /

HOST:www.javait.com/* hosts the host of the requested object * /

user-agent:mozilla/4.5 (WinNT)/* Specify User agent * /

accept:text/html/*html text file * /

ACCEPT-LANGUAGE:ZH-CN/* Specify an acceptable language * /

Content-length:22

Connection:keep-alive

Param1=abc?m2=def/* parameters submitted by * /

3. Parsing HTTP Protocol Response

(1), status line

The status line consists of an HTTP version (http-version), a status code (status-code), and a simple phrase that interprets the status code ( Reason-phrase ) consists of three parts, in the following format:

Http-version Status-code reason-phrase CRLF

The status code consists of three digits, a total of 5 categories , of which the first number specifies the response category, the value is 1-5, and the following two bits have no specific provisions.

1XX: Indicates information, such as a request received or being processed.

2XX: Success.

3xx: Redirect.

4XX: Client error, if the request contains incorrect syntax or does not complete properly.

5xx: Server-side error, such as server failure, cannot complete the request.

For example:

OK Success

304 not Modified unmodified

Error Request

404 Not Found found

The typical response state is explained as follows:

$: Indicates the request was successful and the requested resource was successfully returned.

302/307: Represents a temporary redirect, at which time the requested document has been temporarily moved to another location, and the new URL of the document is given in the site response header.

401: Indicates that the browser is accessing a password-protected page.

403: Indicates that the server received the request but refused to provide the service.

404: Indicates that a resource could not be found, that is, there is no browser requested resource on the server.

$: Indicates an internal server error, that is, the server-side CGI,ASP,JSP , and other programs have been wrong.

503: Indicates that the server is temporarily overloaded and cannot process the current request.

Examples of status lines:

HTTP 1.0 OK

(2), response header

The common response headers are as follows:

Allow: Indicates how the server supports request methods, such as GET,POST , and so on.

Content-encoding: Specifies the encoding method for the document.

Content-length: Specifies the byte length of the data in the response.

Content-type: Specifies the MIME type of the loopback data .

Date: Specifies the day on which the HTTP message is sent.

Last-modified: Specifies the last modified time to return data.

Location: Redirects the requestor to a new URI address.

Refresh: Specifies when the browser refreshes periodically.

Expired: Specifies when the browser caches data.

Server: Specifies the name of the server that contains the SOFTWARE product information used by the server processing the request, as opposed to the user-agent request header.

(3), Response body

The response body refers to the content of the resource returned by the server, such as an HTML page. The response header and response body must be separated by a blank line.

A typical HTTP Response example is as follows:

http/1.1 OK/* status line * /

Connection:close/* Connection Status * /

Date:Wed, 02:20:45 GMT/* date * /

Server:apache/2.0.54 (Unix)/* servers * /

Content-length: 397/* Specifies the length of bytes that the data contains * /

Content-type:text/html/* Specifies the MIME type of the returned data * /

/* Empty line * /

<body>

/* Data * /

</body>

The working mechanism of No1_web

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.