Web working principle and HTTP protocol (basic article)

Source: Internet
Author: User

Web working principle and HTTP protocol (basic article)
1. Common Application Architecture
(1) c/s?Full name Client/sever, i.e. client/server
The C/S architecture software (i.e. client/server mode) is divided into two tiers: client and server.
The first layer is on the client system to combine the representation with the business logic, the user presentation layer, which requires the programmer to write the client itself;
The second layer is the database layer, which combines the database server with the network.

(2) b/S? full name Browser/server, ie browser/server
You can open it as long as you have a browser

2.WEB Working principle
HTTP processing Flow: Establish the connection--the client browser sends the request information--->web the server resolves the request and finds the appropriate resource to make the file and other information into the HTTP response back to the client--close the connection.
three ways to work in 3.WEB
(1) The server does not have the application and the database, requests the HTML file directly

(2) server with application (e.g. PHP)

(3) Server with application and database

4.URL
URL: Uniform Resource Locator
Format: Protocol://domain/directory/File # fragment identifier
Example: http://www.baidu.com/admin/index.php

5.HTTP protocol
(1) HTTP: Hypertext Transfer Protocol, working on client-server architecture. The browser sends all requests through the URL to the HTTP server as the HTTP client, the Web servers, and the Web server sends the response information to the client, based on the received request.
(2) Features: simple, fast, flexible, no connection.
(3)HTTP request :
Include: request line, request header, blank line, request data

POST / HTTP1.1Host:www.wrox.comUser-Agent:Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)Content-Type:application/x-www-form-urlencodedContent-Length:40Connection: Keep-Alivename=Professional%20Ajax&publisher=Wiley

The first part: The request line, the first line indicates the POST request, and the http1.1 version.
The second part: The request head, the second line to the sixth line.
Part Three: blank line, blank line in line seventh.
Part IV: Request data, line eighth.
(4) response
Includes: status line, message header, blank line, and response body

HTTP/1.1 200 OKDate: Fri, 22 May 2009 06:07:21 GMTContent-Type: text/html; charset=UTF-8

The first part: The status line, consists of the HTTP protocol version number, the status code, the status message three parts.
The first behavior status line, (http/1.1) indicates that the HTTP version is 1.1, the status code is 200, and the status message is (OK)
Part II: Message headers that describe some additional information that the client will use
The second and third behavior message headers, Date: The day and time the response was generated; Content-type: Specifies the MIME type of HTML (text/html), which is the encoding type UTF-8
Part Three: blank line, a blank line after the message header is required
Part IV: The response body, the text information that the server returns to the client.
The HTML portion following the empty line is the response body.
(5)Status Code
A three-digit number, the first number defines the category of the response, divided into five categories:
1XX: Indication information--Indicates that the request has been received and continues processing
2XX: Success-Indicates that the request has been successfully received, understood, accepted
3XX: Redirect--further action is required to complete the request
4XX: Client Error--Request syntax error or request not implemented
5XX: Server-side error-the server failed to implement a legitimate request
Common Status Codes:
$ OK//client request succeeded
Bad Request//client requests have syntax errors and cannot be understood by the server
401 Unauthorized//request without Grant
403 Forbidden//server receives request, but refuses to provide service
404 Not Found//request resource not present, eg: Wrong URL entered
Internal Server error//server unexpected errors
503 Server Unavailable//server is currently unable to process client requests and may return to normal after some time
(6)Request Method
HTTP requests can use a variety of request methods, depending on the HTTP standard.
GET: Requests the specified page information and returns the entity principal.
HEAD: Similar to a GET request, except that there is no specific content in the returned response to get the header (commonly used in scanners, very fast scanning, such as the Imperial Sword Software)
POST: Submitting data to a specified resource for processing requests (such as submitting a form or uploading a file)
PUT: Supersedes the contents of the specified document from the data that the client sends to the server.
Delete: The requested server deletes the specified page.
OPTIONS: Allow clients to view server performance.
TRACE: Echo the request received by the server, primarily for testing or diagnostics.
(7) Common HTTP fields
Referer (Exploit: cross-site request forgery)
Content-type?
X-forwarded-for (Forged batch contract, using: Swipe ticket tool)

Web working principle and HTTP protocol (basic article)

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.