Enter the url to the page loads all what happened? (A software testing interview questions)

No article first appeared in public: Software Testing er

 

Enter the url to the page loads all what happened? This is a software testing interview questions, and in fact there are many knowledge question is asked:

Question 1 Please talk about the three-way handshake tcp

OK so you better put this in mind, the next interview: Question 2 tcp and http What is the difference? ?

Question 3 http and https difference?

Question 4 http request method?

Question 5 common return status codes What? What is the meaning? . . .
At first I just deal with the interview, to understand these issues, but found himself not well understood. And before and after the test needs to be positioned in the usual mid-bug and test interfaces do you need to understand that knowledge.
So I use this sort of question about this knowledge, deepen their understanding, we hope to help you.


Enter the url to the page loads overall process is summarized below:

1, the address bar of the browser, enter the URL and press Enter.

2, browser cache DNS lookup record of the current URL.

3, DNS parse URL corresponding IP.

4, establish a TCP connection (three-way handshake) based on IP.

5, HTTP requests initiated.

6, the server processes the request, the browser receives the HTTP response.

7, page rendering, build a DOM tree.

8, closes the TCP connection (four wave).


Again describe in detail

First, the example of the inputting https://www.baidu.com/ the domain consists of three parts: the protocol name, the domain name, port number, this port is the default port number hidden (HTTP default port 80, HTTPS default port 443.). Protocol: https domain: www.baidu.com, used to uniquely name the site location / This is the root directory, that is, through the website to find the server name, and then stored in the root directory of the web server


Two, DNS DNS name resolution process is actually the domain name to revert to process IP address (this process is an overview on the line): ① Query Browser cache whether there is a current URL DNS cache records ② operating system cache (as you local host file bundled ip) ③ query the local domain name server (DNS approximately 80% completed here, this server is generally somewhere in your city) or more domain name resolution is not yet complete, the local domain name the server continues to send a query to the other root name servers ...........


Third, establish tcp connection after obtaining the IP address (three-way handshake popular version) The first handshake: the client and server to communicate, we must first inform the server soon, then issue a connection request signal SYN = 1 " server brother, I want to talk to you. " The second handshake: When the server receives the connection request from a client, this time to give the client a confirmation message, "I know (ACK), I am here ready, you can now connect it (SYN)" . Third handshake: When the client receives confirmation of the server connection information, to be polite to inform the server about, "Okay, let's start now Unicom (ACK)". Establish a connection to this whole process has been completed, the next step is a process both of you even while I was an exchange of the transmission of information.


Fourth, the browser sends an HTTP request to the server common request method

No. method description
1 GET Request page information specified, and returns the entity body.
2 HEAD Similar to the GET request, returns a response but not the specific content, for obtaining the header
3 POST Submitting data to the processing request specified resource (e.g., file submission form or upload). Data contained in the request body. POST request may result in a revision to establish and / or existing resources to new resources.
4 PUT Data transmitted from the client to the server designated to replace the contents of the document.
5 DELETE Requests the server to delete the specified page.
6 CONNECT HTTP / 1.1 protocol can be reserved for connection to the proxy server pipeline mode.
7 OPTIONS It allows the client to view server performance.
8 TRACE Echo request received by the server, mainly for testing or diagnosis.
9 PATCH It complements the PUT method, used locally known resource update.

 You can click F12 to view the request method

 

Fifth, the browser cache


Sixth, the browser receives the response  

服务器在收到浏览器发送的HTTP请求之后,会将收到的HTTP报文封装成HTTP的Request对象,并通过不同的Web服务器进行处理,处理完的结果以HTTP的Response对象返回,主要包括状态码,响应头,响应报文三个部分。

 

状态码主要包括以下部分

1xx:指示信息–表示请求已接收,继续处理。

2xx:成功–表示请求已被成功接收、理解、接受。

3xx:重定向–要完成请求必须进行更进一步的操作。

4xx:客户端错误–请求有语法错误或请求无法实现。

5xx:服务器端错误–服务器未能实现合法的请求。
看到响应码500等5xx类型,一般是在开发人员在操作,不要着急提bug哦
  响应头主要由Cache-Control、 Connection、Date、Pragma等组成。响应体为服务器返回给浏览器的信息,主要由HTML,css,js,图片文件组成。如下 

七、页面渲染

八、关闭TCP连接

四次挥手断开连接通俗版:

第一次挥手:双方交流的差不多了,此时客户端也已经结尾了,接下来要断开通信连接,所以告诉服务端“我说完了(FIN)”,此时自身形成等待结束连接的状态。 

第二次挥手:服务端知道客户端已经没话说了,服务端此时还有两句话要给客户端说“我知道你说完了(ACK),我再说两句&*…%¥”…

 第三次挥手:此时客户端洗耳恭听继续处于等待结束的状态,服务器端也说完了,自身此时处于等待关闭连接的状态,并对告诉客户端,“我说完了,咱们断了吧(FIN)”。 

第四次挥手:客户端收知道服务端也说完了,也要告诉服务端一声(ACK),因为连接和断开要双方都按下关闭操作才能断开,客户端同时又为自己定义一个定时器,因为不知道刚才说的这句话能不能准确到达服务端(网络不稳定或者其他因素引起的网络原因)。所以默认时间定为两个通信的最大时间之和,超出这个时间就默认服务器端已经接收到了自己的确认信息,此时客户端就关闭自身连接,服务器端一旦接收到客户端发来的确定通知就立刻关闭服务器端的连接。 到此为止双方整个通信过程就此终结。 这里要声明一下:断开链接不一定就是客户端,谁都可以先发起断开指令,另外客户端和服务端是没有固定标准的,谁先发起请求谁就是客户端。 

再来看一下这几个问题

Question 1请讲一下tcp三次握手

见上文
Question 2 tcp和http有什么区别??

http基于TCP连接HTTP协议中的数据是利用TCP协议传输的,所以支持HTTP也就一定支持TCPTCP是传输层(底层通讯协议),定义的是数据传输和连接方式的规范HTTP是应用层协议,定义的是传输数据的内容的规范
Question 3 http和https区别?

1、http明文传输,连接无状态;HTTPS协议是由SSL+HTTP协议构建的可进行加密传输、身份认证的网络协议,比http协议安全。

2、https协议需要到CA申请证书,一般免费证书较少,因而需要一定费用。

3、http端口80,https端口443。HTTP:超文本传输协议。是一个客户端和服务器端请求和应答的标准,用于从服务器传输超文本到本地浏览器的传输协议。HTTPS:加了密的HTTP。HTTPS=HTTP+TLS或SSL,SSL(Secure Sockets Layer 安全套接层),及其继任者传输层安全(Transport Layer Security,TLS)
Question 4 http请求方法?见上文
Question 5常见的返回状态码有哪些?都是什么含义?见上文

 

文章首发于公众号:软件测试er

Guess you like

Origin www.cnblogs.com/lrence/p/11929318.html