When we hit Enter enter the URL from the browser, client and server do what

When we hit Enter enter the URL from the browser, client and server did
============================== =========
client-side processing (in order to get a web server)
1. users enter the URL address (uniform resource locator) in the browser, it is positioned at the location of the web server
2. the browser send request to find the page the URL points (user Enter)
. browser parses the URL address => domain name + path + port information, etc.
the browser initiates a DNS system call, the purpose is to find the corresponding domain name server IP
. browser to view the browser if there is no local cache (you can see in the browser), if there is direct access
. If your browser does not correspond to the cache found, to the operating system continue to resolve the DNS,
. operating system to check the operating system itself has no cache (host file), if there is direct access to the browser
. If you are not found, the DNS server will initiate a system call (DNS server is a ip, assigned by the carrier, there is a broadband connection)
. the system initiates a DNS server resolution request, DNS will resolve domain names to return for an IP Browser access
3.DNS server
. DNS does not return directly to IP, such as baidu.com, this is a com top-level domain, and the DNS service broadband
service just know the addresses of these top-level domain server, and then let the system go to the corresponding server com to resolve the IP,
because they owned the domain name, but if it is the beginning of the www, you also need to look further let baidu server
so that the sub-domains with the deeper
the longer the DNS resolution process, the longer the time, some domain name there is no www domain
Summary: DNS server returns the IP page, but if not, it will return an IP domain name server
we find the server that calls to resolve, if not continue to return the associated DNS server IP, until looking
up to, and ultimately returned to the browser,
4: the browser will establish a connection between a channel and server
each server is like a closed building, IP equivalent of martial street number, the port is equivalent to open doors
within the network, all of IP is one island, if you want to connect, you need to connect a channel,
and the browser also need to give this machine "open" (open ports), the browser will establish a connection through a local random port
5: The browser will Some information of the client into "packets"
this "packet" is sent to the server via the connection passage
"package" includes information, browser version, browser information, mode request, cache, etc.
~~~ client's operating point ended ~~
server processing
1: server receives the browser's "package"
2: At this web Server (Apache) debut, Apache Direct listening on port 80 (default)
3: As has been listening on port, so the "package" to enter the web Server (Apache) inside, began treatment
4: Open submitted by the client over the "package", to get inside the package request path (to know that there are things)
5: extension of the file corresponding to the path to find the requested file MIME type (text / html), mine.types profile
corresponding to one kind of a type of MIME type
6: determining the file type static files or dynamic file
7: If it is a dynamic file, Apache priority inquiry brother (module file) if you can handle the file, if not all, the Apache
are handled (Apache can not handle dynamic file) in accordance with the static files
php file to read the code and dynamic execution.
The execution. Server returns the results to the Web (the Apache)
8: If a static file directly read the contents of this file
9: server data will be sent to the client to make a "package"
10: connect through this before, "package" through the channel back to the client
to return "package"
contains an HTML and some additional information about
a client rendering stage
1: open the server returns over the "package" to find contentType
2: contentType content according to decide how to handle the response ( there css, html, js, images, etc.)
3: If the interface has js, css, picture connection, there is need to send a request to repeat all of the above processes

will eventually effect the page is displayed to the user on the browser window


=======================================
HTTP protocol
refers to the rules package, to make the browser or the client can read, you need to abide by certain rules, which is HTTP
(hyperText transfer protocol)
standard talk is: a standard protocol for communication between computers, such agreements restrict the content and format of each communication the meaning of items
,
including: . Request / response message format
. Request method - GET / the POST
. Response Status --200 / 404/302/304
. The default request / response header
message
// in the browser tab under Network control panel inside view
http protocol defines request / response message format
requesting browser package "package" called "request packet
web Server package response "packet" is called the "response message"
request packet format is:
request line GET / index.html HTTP / 1.1
request header the Host: Baidu.com
connecton: Keep-Alive
the User-- Agent: the Mozilla / 5.0 (10 ... window ...
the Accept: text / HTML, file application .....
......
empty line
request ...... body (normally get request body are empty)
response packet:
the status line HTTP /1.1 200 OK
响应头 Date:Tue,26 Sep 2017 10:23:04 GMT
Connection:keep-alive
Keep-Alive:timeout=5,max=96
Content-Type:text/html
Content-Length:16228
空白行
响应体 <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<form action="<?php echo ($_SERVER['PHP_SELF']);?>" method="post" enctype="multipart/form-data">
<input name="abc" type="file">
<button>提交</button>
</form>
</body>
</html>ordinary the text can only transmit information, there is a hypertext format, such as html, dochypertextbut we can submit the form by post method, the form of the body such request information which is submitted inbecause the method is to get the url address transmitted through the data, so there is no request body of data
Also sends a request message when the form is submitted




HTTPS
HTTPS is a secure version of http, the packet is encrypted, more secure
content-Type
followed by the file format needs to be resolved, if it is text / html will be parsed into a web browser, if it is text / css will resolve to style file
if it is text / javascript they are interpreted as js page,
so the browser parses the file suffix is not standard, but the type of response header content-type statement as a standard
additional content-type encoding format will declare page , UTF-8, GBK this, garbled multi-page input is parsed and
inconsistent coding,
PS: If your browser can not resolve certain format, download box will pop up, allowing users to download the file
PHP header () function
header () function is used to set the response header information header, such as
header ( "content-type: UTF -8") encoding format statement
header ( "loaction: www.baidu.com") page redirect (Jump to specify the page), remember not directed to the current page, or will be error
can also modify a lot of header information. . . . .

HTTP session
1.Cookie
very important feature of HTTP is a stateless (every time we met is "first meeting"), If you simply want a program by program end of our service
to remember every visitor is not possible, you must use Some tools allow the server to remember the client, this means that Cookie
Cookie is like a small supermarket ticket to consumers by supermarkets (Server) to the consumer (Browser), supermarkets need to remember that every consumer, but
by small ticket know (the submitted data, identification of the user) before consumers consumer information
role:
to verify the user name before us, or upload files when certain data requirements can not be accepted as the service side, we will use the last GET the
data to fill, but once you leave this page will follow the destruction of this data, at any time when we all want access to the last upload data
which need to use Cookie, which allows the server to identify the current client (browser device) and submitted prior to remember the data, the operation to make
an example: website Remember the login user name, free web advertising a particular client Advertising (specific display)

Guess you like

Origin www.cnblogs.com/loveHtml/p/12102552.html