15. Toad Notes Go language--web programming concept

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

15. Toad Notes Go language--web programming concept

Go now has a sophisticated HTTP processing package, which makes it easy to write dynamic Web programs that do anything.

Web Principles

The browser itself is a client, when you enter the URL, the first browser will go to request a DNS server, through DNS to obtain the corresponding domain name corresponding IP, and then through the IP address to locate the IP corresponding server, the request to establish a TCP connection, and so the browser sent out the HTTP After requesting the packet, the server receives the request packet before it starts processing the request packet, the server calls its own service, returns an HTTP Response (response) packet, and the client receives a response from the server and starts rendering the body of the Response package. The TCP connection to the server is then disconnected when all content is received.

Concept

The URL (Uniform Resource Locator) is the abbreviation for "Uniform Resource Locator" that describes 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

HTTP protocol Detailed

The HTTP protocol is the core of web work, so knowing how the Web works is a good way to get a detailed understanding of how HTTP works.

HTTP is a protocol that allows Web servers and browsers (clients) to send and receive data over the Internet, which is built on the TCP protocol and typically uses TCP port 80. It is a request, response protocol--the client makes a request and the server responds to the request. In HTTP, the client always initiates a transaction by establishing a connection and sending an HTTP request. The server cannot actively contact the client or send a callback connection to the client. A connection can be interrupted prematurely by both the client and server side. For example, when a browser downloads a file, you can turn off the HTTP connection to the server by clicking the "Stop" button to interrupt the download of the file.

The HTTP protocol is stateless, and there is no correspondence between this request and the last request of the same client, and it is not known to the HTTP server whether the two requests are from the same client. To solve this problem, the Web program introduces a cookie mechanism to maintain the sustainable state of the connection.

The HTTP protocol is built on top of the TCP protocol, so a TCP attack can affect HTTP traffic as well, such as some common attacks: SYN Flood is one of the most popular DOS (denial of service attacks) and DDoS (distributed denial of service attacks) in the current way, This is a way to exploit a TCP protocol flaw that sends a large number of bogus TCP connection requests, which can cause the attacker to run out of resources (CPU full load or low memory).

The HTTP protocol defines a number of request methods that interact with the server, with 4 basic types, get,post,put,delete. 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.

HTTP request Package

Request package structure, the request package is divided into 3 parts, the first part is called Requestline (Request line), the second part is called the request header (header), the third part is the body (body).

HTTP Response Package

The first line in the response package is called the status line, which consists of the HTTP protocol version number, the status code, and the status message.

Related 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.