HTTP protocol Learning record and summary

Source: Internet
Author: User

First, preface

Today's Web application technology is a kind of contention, such as ASP. NET, PHP, JSP and so on. However, regardless of how Web application technology develops in the future, understanding the basic communication Protocol of a Web application is important for understanding how the Web program works inside. The following will be explained in various ways:

Second, what is the HTTP protocol

The protocol is the basic rule for communication between two computers, and Hypertext Transfer Protocol (HTTP) is a TCP/IP-based application layer protocol that enables Hypertext Markup Language (HTML) to be transferred from the Web server to the client browser.

The HTTP protocol is stateless, that is, it does not have a memory function, for this time the request is not related to the last request, do not know whether the request from the same client. To solve this problem, the Web program introduced a session, a cookie to record the authenticated user information to record the status.

  

Third, browser, proxy server, server

When we want to request resources from the server, we only need to enter the URL in the browser, but what is the principle and process of the request, the response?

When we enter a URL in the browser to send a request to the server, the server obtains the Resquest request, handles the request accordingly, generates the corresponding reponse and sends it to the client browser, and the HTML in the browser parsing reponse finally renders the page.

It is possible that our request was passed through a proxy server and finally arrived at the Web server.

Proxy server is the intermediary of network information, what is the role of it?

1. Improve Access speed

2, the breakthrough limit, that is, FQ

3, Hidden identity.

Iv. URL Interpretation

The URL (Uniform Resource Locator) address is used to describe a resource on a network with the following basic format

Schema://host[:p ort#]/path/.../[?query-string][#anchor]

Scheme specifies the protocol used by the lower layer (for example: HTTP, HTTPS, FTP)

The IP address or domain name of the host HTTP server

The default port for the port# HTTP server is 80, in which case the lower number can be omitted. If you use a different port, you must specify, for example, http://www.cnblogs.com:8080/

Path to access resource

Query-string data sent to the HTTP server

anchor-Anchor

V. Structure of HTTP messages

  Let's look at the structure of the request message, which consists of three parts. The first part is request line, the second part is the request header, the third part is body.

The first part of method represents the request method, Path-to-resource represents the path to the requested resource Http/version-number represents the protocol version number. When the request method is get, the data that is passed to the server is appended to the URL as query string, and the body is empty.

Let's look at the structure of the reponse message, which is basically the same as the structure of the request message, and is divided into three parts. The first part reponse line, the second part is divided into reponse header, the third part is body. The structure diagram is as follows:

The Http/version-number represents the version number of the HTTP protocol, and status code indicates that the message indicates a status.

Here are the similarities and differences between the two most common request modes of post get.

The HTTP protocol defines a number of ways to interact with the server, the most basic of which are 4, get,post,put,delete, respectively. A URL address is used to describe a resource on a network, and the Get, POST, PUT, delete in HTTP corresponds to the search for this resource, change, increase, delete 4 operations. Our most common is get and post. Get is typically used to get/query resource information, and post is typically used to update resource information.

Let's look at the difference between get and post

1. Get submitted data will be placed after the URL, to split the URL and transfer data, the parameters are connected with &, such as editposts.aspx?name=test1&id=123456. The Post method is to put the submitted data in the body of the HTTP packet.

2. The data size of the Get commit is limited (because the browser has a limit on the length of the URL), and there is no limit to the data submitted by the Post method.

3. The Get method needs to use Request.QueryString to get the value of the variable, while the Post method obtains the value of the variable by Request.Form.

4. The Get method submits the data, which brings security issues, such as a login page, when the data is submitted by get, the user name and password will appear on the URL, if the page can be cached or other people can access the machine, you can obtain the user's account and password from the history.

HTTP protocol Learning record and summary

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.