Linux Web Services (HTTP HTML DNS)

DNS domain name resolution

DNS is responsible for translating domain names into IP addresses.

The detailed introduction is well documented in the previous blog.

Here is a review of the DNS resolution process.

Domain Structure

hostname.subdomain.[second-level domain].top-level domain.
                    (root domain)


DNS resolution process (interview questions)

Client -> local caching domain name server -> root domain server -> secondary domain server -> subdomain server -> resolve IP according to host name (iterative, recursive)

The parsing process is divided into iterative mode and recursive mode.

Iterative query is more commonly used, because it is not as easy to occupy the resources of the upper domain server as recursive query

Recursive pattern parsing process

The client sends a request to find the local cache domain server, if there is no

Forward relevant requests to the root domain server for resolution,

The root domain server forwards the request to the corresponding top-level domain server,

The top-level domain server then forwards it to the second-level domain server,

The second-level domain server forwards it to the sub-domain server, and resolves the IP address according to the host name.

The data is returned to the client layer by layer, and the client can use the IP address to access the host of the other party.

At the same time, the corresponding relationship of domain server records is cached locally for the next visit.

Iterative schema parsing process

The client sends a request to find the local cache domain server, if there is no

Send a resolution request to the root domain server and return the address of the top-level domain server

Send a resolution request to the top-level domain server and return the address of the second-level domain server

Send a resolution request to the secondary domain server and return the address of the subdomain server

Send a resolution request to the subdomain server, resolve the IP address and return the result to the local cache domain server

The local cache domain server returns the result to the client, and records the corresponding relationship for the next visit

TCP three-way handshake

TCP three-way handshake and four-way handshake are used to establish a connection before HTTP protocol communication.

The detailed introduction is well documented in the previous blog.

Here is a brief review of the TCP three-way handshake and four-way handshake process.

  1. The first handshake: When the connection is established, the client sends a syn packet (seq=x) to the server, and enters the SYN_SENT state, waiting for the server to confirm
  2. Second handshake: The server receives the syn packet and must confirm the client’s SYN (ack=x + 1), and at the same time send a SYN packet (seq =y), that is, the SYN + ACK packet, at this time the server enters the SYN_RECV state.
  3. The third handshake: the client receives the server’s SYN + ACK package, sends a confirmation package ACK (ack=y + 1) to the server, and this package is sent After completion, the client and server enter the ESTABLISHED (TCP connection successful) state and complete the three-way handshake.

Brief description: pc1 sends a SYN message to pc2, pc2 replies a SYN + ACK message after receiving it, and pc1 replies an ACK message after receiving it, and both ends enter the established state.

TCP waved four times

Brief description: pc1 sends a FIN message to pc2, pc2 replies with an ACK message after receiving it, and then replies with a FIN + ACK message after the data transmission is completed, pc1 sends an ACK message after receiving it, and enters the time wait stage , close the connection after waiting for 2MSL. pc2 also closes the connection after receiving the ACK.

For a detailed description, please refer to the previous blog post

HTML

HTML is called Hypertext Markup Language, which is a specification and a standard, and it uses markup symbols to mark various parts of the webpage to be displayed. A web page file itself is a text file. By adding tags to the text file, you can tell the browser how to display the content.

HTML files can be edited with any text editor that can generate txt files to generate hypertext markup language files, just modify the file name suffix to “.html” or “.htm”.

HTML basic tags

(1) HTML grammar rules
HTML tags adopt the form of double tags, and the front and rear tags correspond to each other, indicating the start and end of the tag respectively, and the content in the middle of the tag is described by the tag. The front tag is represented by ““, and the end tag has one more “/”, which is represented by ““.
(2) HTML file structure
The outermost layer of an HTML file is represented by , indicating that the file is described in HTML language. Inside it are parallel header tags () and content tags (). The most basic HTML file structure is as follows:

<html>
    <head>Description information of the content of the web page</head>
    <body>The content displayed on the webpage</body>
</html>

●Tags commonly used in header tags:

label description
</td> <td>Defines the title of the document</td> </tr> <tr> <td><base> </td> <td>Defines the default link address of the page link tag</td> </tr> <tr> <td><link> </td> <td>Defines the relationship between a document and external resources</td> </tr> <tr> <td><meta></td> <td>Defines metadata in HTML documents</td> </tr> <tr> <td><script></td> <td>Defines the script file of the client</td> </tr> <tr> <td> <style></td> <td>Defines the style file of the HTML document</td> </tr> </tbody> </table> <p>● Commonly used tags in content tags</p> <table border="1" cellpadding="1" cellspacing="1" style="width:500px;"> <thead> <tr> <th>label</th> <th>description</th> </tr> </thead> <tbody> <tr> <td> <table></td> <td>Define a table</td> </tr> <tr> <td> <tr></td> <td> defines a row in the table</td> </tr> <tr> <td> <td></td> <td> defines a column in a row in the table</td> </tr> <tr> <td><img> </td> <td>Defines an image</td> </tr> <tr> <td><a></td> <td>Defines a hyperlink</td> </tr> <tr> <td> </td> <td>Defines a line</td> </tr> <tr> <td></td> <td>Defines newline</td> </tr> <tr> <td><font> </td> <td>Defines font</td> </tr> <tr> <td > <h1></td> <td> Define font size</td> </tr> </tbody> </table> <p> <img alt="" height="212" src="//i2.wp.com/img-blog.csdnimg.cn/5444ac4ff33a461182eb1f2ef5f66cec.png" width="460"></p> </blockquote> <blockquote> <h2>Static and dynamic pages</h2> <p><strong>1. Static pages</strong><br /> In website design, web pages in pure HTML format are usually called "static web pages". Static web pages are standard HTML files, and their file extensions are .htm and .html. Static web pages are the basis of website construction, and early websites were generally made of static web pages. Various dynamic effects can also appear on static web pages, such as animation in .GIF format, FLASH, scrolling subtitles, etc. These "dynamic effects" are only visual, and are different concepts from the dynamic web pages that will be introduced below.</p> <p><strong>2. Dynamic pages</strong><br /> The so-called dynamic webpage refers to a webpage programming technology that is opposite to the static webpage. For static web pages, with the generation of HTML code, the content and display effect of the page will basically not change-unless the page code is modified. This is not the case for dynamic web pages. Although the page code has not changed, the displayed content can change with time, the environment, or the results of database operations. The suffixes of dynamic webpage URLs are not .htm, .html, .shtml, .xml and other common webpage production formats for static webpages, but .aspx, .asp, .jsp, .php, .perl, .cgi, etc. , and there is an iconic symbol - "?" in the URL of the dynamic web page.<br /> Dynamic web pages are the integration of basic html grammar specifications and advanced programming languages such as Java, PHP, C#, database programming and other technologies, in order to achieve efficient, dynamic and interactive management of website content and style. Therefore, in this sense, all webpages generated by webpage programming techniques combined with advanced programming languages other than HTML and database technology are dynamic webpages.</p> <p><strong>3. Dynamic Web Language</strong><br /> Early dynamic web pages mainly used CGI (Common Gateway Interface) technology. Although CGI technology has matured and has powerful functions, it tends to be gradually replaced by new technologies due to programming difficulties, low efficiency, and complicated modification.</p> <p>Currently commonly used dynamic web page programming languages are as follows:</p> <blockquote> <p>●PHP<br /> That is, Hypertext Preprocessor (hypertext preprocessor), which is the most popular scripting language on the Internet today. Its syntax borrows from C, Java, PERL and other languages, but you can use PHP to create a real script with very little programming knowledge. Interactive Web site.</p> <p>●JSP<br /> That is, Java Server Pages (Java Server Pages), which is a new technology launched by Sun Microsystem in June 1999, is a Web development technology based on Java Servlet and the entire Java system.</p> <p>●Python<br /> It is an object-oriented, cross-platform dynamic computer-like programming language. It was originally designed for writing automation scripts (shells). With the continuous updating of versions and the addition of new language features, it is increasingly used in independent Large-scale project development.</p> <p>●Ruby<br /> It is a simple and fast object-oriented (object-oriented programming) scripting language developed by Japanese Yukihiro Matsumoto in the 1990s and complies with the GPL agreement and Ruby License. Its inspiration and features come from Perl, Smalltalk, Eiffel, Ada, and Lisp languages.</p> </blockquote> <h3></h3> <h3></h3> <h3>The difference between dynamic pages and static pages</h3> <p><strong>Static webpage</strong>: It is a standard HTML file with extensions of .htm and .html, no background database support, no application program and no interactive webpage, and the URL does not contain "?"<br /><strong>Dynamic page</strong>: Supported by a background database, the page can be interactive and automatically updated, including applications. The extension is usually suffixed in the form of .php, .jsp, .py, .ruby, .perl, etc. The iconic "?" in the page URL</p> </blockquote> <blockquote> <h2>Overview of the HTTP protocol</h2> <p> The HTTP protocol uses a request/response model. The client sends a request to the server. The request header contains the requested method, URL, protocol version, and a MIME-like message structure including request modifiers, client information, and content. The server responds with a status line containing the message protocol version, success or error encoding plus server information, entity meta information, and possibly entity content.</p> <p><img height="432" src="//i2.wp.com/img-blog.csdnimg.cn/20190612183324723.png?" width="491"></p> </blockquote> <p> </p> <p><center></center></p> <blockquote> <h2><strong>HTTP version (interview questions)</strong></h2> <p>(1) HTTP/0.9: Obsolete. Only accepts GET as a request method, does not specify a version number in the communication, and does not support request headers. Since this version does not support the POST method, the client cannot pass much information to the server.<br /> (2) <strong>HTTP/1.0</strong>: plain text transmission; TCP connection will be closed immediately after http response; support http header information (such as http protocol version number, status code, etc.)</p> <p><img alt="" height="279" src="//i2.wp.com/img-blog.csdnimg.cn/img_convert/0e32afcd1c62eb8b882f1cefb4258a5f.png" width="466"></p> <p> (3) HTTP/1.1: Persistent connections (long connections) are introduced, that is, TCP connections are not closed by default and can be multiplexed by multiple requests, which can work well with proxy servers. Also supports pipelining mechanism (implementing multiple http requests and responses in the same TCP connection)</p> <p><img alt="" height="288" src="//i2.wp.com/img-blog.csdnimg.cn/img_convert/c2c5bbf2902fd5beb5e635c99dbbf03a.png" width="387"></p> <p> (4) <strong>HTTP/2.0</strong>: Binary transmission; supports long connection and complete multiplexing, in a TCP connection, both the client and the browser can send multiple requests or responses at the same time, without One-to-one correspondence in order. A header information compression mechanism is introduced, which can be compressed with gzip or compress before sending. Support server-side push, allowing the server to actively send resources to the client without request.</p> <p><img alt="" height="433" src="//i2.wp.com/img-blog.csdnimg.cn/img_convert/9bbdd2da130ec353f683cc7f1b3b2bd6.png" width="436"></p> <p>(4) HTTP/3.0: based on UDP protocol</p> </blockquote> <blockquote> <h2><strong>HTTP Methods (Interview Questions)</strong></h2> <p>HTTP supports several different request commands, which are called HTTP methods. Each HTTP request message contains a method to tell the server what action to perform, including: get a page, run a gateway program, delete a file, etc. The most commonly used methods for obtaining resources are GET, POST, and PUT.</p> <table border="1" cellpadding="1" cellspacing="1" style="width:700px;"> <tbody> <tr> <td style="width:99px;">HTTP method</td> <td style="width:599px;">description</td> </tr> <tr> <td style="width:99px;"><strong>GET</strong></td> <td style=" width:599px;">Send query request resources, read or download resources, just like the select operation of the database</td> </tr> <tr> <td style="width:99px;"><strong>PUT </strong></td> <td style="width:599px;">Submit data to the server, modify resources, and will not increase the type of data, etc. Resource updates are like database update operations</td> </tr> <tr> <td style="width:99px;"><strong>DELETE</strong></td> <td style="width:599px;">Delete resources, just like the delete operation of the database</td> </tr> <tr> <td style="width:99px;"><strong>POST </strong></td> <td style="width:599px;"> is used to send a request containing user-submitted data Insert or create resources This request will change the type of data and other resources, just like the insert operation of the database, it will create new content. Almost all submission operations currently use POST requests. </td> </tr> <tr> <td style="width:99px;"><strong>HEAD</strong></td> <td style="width:599px;">Request the head of the webpage Information, query meta information</td> </tr> </tbody> </table> <h3> GET and POST comparison</h3> <blockquote> <p>●GET method: get data from the specified server<br /> GET requests can be cached<br /> GET requests will be saved in the browser's browsing history<br /> GET requests have a length limit<br /> Mainly used to get data<br /> The query string will be displayed in the URL suffix, which is not safe, such as http://www.test.com/a.php?Id=123</p> </blockquote> <blockquote> <p>●POST method: submit data to the specified server for processing<br /> POST requests cannot be cached<br /> POST requests will not be saved in the browser's browsing history<br /> POST requests have no length limit<br /> The query string will not be displayed in the URL, which is safer</p> </blockquote> </blockquote> <blockquote> <h2>HTTP Status Code<strong>(Interview Question)</strong></h2> <p> HTTP Status Code (HTTP Status Code) is a 3-digit code used to indicate the HTTP response status of the web server. When the browser requests a certain URL, the server returns the corresponding processing status according to the processing status.<br /> Usually the normal status code is 2xx, 3xx (such as 200), if there is an exception, it will return 4xx, 5xx (such as 404).</p> <table border="1" cellpadding="1" cellspacing="1" style="width:500px;"> <tbody> <tr> <td>The first position of the status code</td> <td>Defined range</td> <td>Classification</td> </tr> <tr> <td>1xx </td> <td>100-101 </td> <td>Information Tips</td> </tr> <tr> <td>2xx </td> <td>200-206</td> <td>Success</td> </tr> <tr> <td>3xx </td> <td>300-305</td> <td>Redirect</td> </tr> <tr> <td>4xx </td> <td>400-415 </td> <td>Client Error</td> </tr> <tr> <td>5xx </td> <td>500-505</td> <td>Server Error</td> </tr> </tbody> </table> <h3><strong>HTTP Common Status Codes (Interview Questions)</strong></h3> <table border="1" cellpadding="1" cellspacing="1" style="width:700px;"> <tbody> <tr> <td>Status Code</td> <td>Function Description</td> </tr> <tr> <td>200</td> <td>Everything is OK</td> </tr> <tr> <td>301</td> <td>Permanent Redirect</td> </tr> <tr> <td>302</td> <td>Temporary Redirect</td> </tr> <tr> <td><strong>401</strong></td> <td>User Name or password error</td> </tr> <tr> <td><strong>403 </strong></td> <td>Access denied, client IP/host name blocked</td> </tr> <tr> <td><strong>404</strong></td> <td>The requested file does not exist, the URL path requested by the client is wrong, and the corresponding path of the server does not have the webpage file</strong></td> <td> td></tr> <tr> <td>414</td> <td>The request URI header is too long</td> </tr> <tr> <td>500</td> <td> inside the server </td> </tr> <tr> <td><strong>502 </strong></td> <td><strong>Bad Gateway, the proxy server receives the message from Invalid/error response from end server, gateway replies to client 502</strong></td> </tr> <tr> <td><strong>503</strong></td> <td>current </td> </tr> <tr> <td><strong>504</strong></td> <td><strong>Gateway request timed out caused by service unavailable, server overload or maintenance (downtime) , the proxy server cannot receive the response from the backend server within the specified time (response timeout), and the gateway replies to the client with 504</strong></td> </tr> </tbody> </table> <p> <img alt="" height="306" src="//i2.wp.com/img-blog.csdnimg.cn/cb9a98df2ae64a18b9c72cad8d51a0f8.png" width="799"> </p></blockquote> <blockquote> <h2>HTTP request process analysis</h2> <p>When the user enters the URL in the browser to access, an HTTP request message is initiated, and the request includes the request line, request header, and request body. After receiving the request, the server returns a response message, including the status line, response header, and response body.</p> <h3>HTTP protocol message format</h3> <blockquote> <h3><strong> 1. Request message</strong></h3> <p><strong>Request line</strong>: The request line consists of three parts: <strong>Request method, URL and protocol version</strong>.<br /><strong>Request Header</strong>: <strong>Meta information of key-value type</strong>. The request header adds some additional information to the request message, consisting of "name/value" pairs, one pair per line, and the name and value are separated by a colon.<br /><strong>Blank line</strong>: There will be a blank line at the end of the request header, indicating the end of the request header, followed by the request body. This line is very important and essential.<br /><strong>Request body</strong>: The request body is the parameter submitted by the request. The GET method has specified the parameters in the URL, so there is no data when submitting. <strong>The parameters submitted by the POST method are in the request body</strong>.</p> <table border="1" cellpadding="1" cellspacing="1" style="width:650px;"> <thead> <tr> <th>request header</th> <th>description</th> </tr> </thead> <tbody> <tr> <td>Host</td> <td>The address of the server that accepts the request, it can be IP: port number, or domain name</td> </tr> <tr> <td>User-Agent </td> <td>The name of the application that sent the request</td> </tr> <tr> <td>Connection </td> <td>Specify the properties related to the connection, Such as Connection:Keep-Alive</td> </tr> <tr> <td>Accept-Charset </td> <td>Notify the server of the encoding format that can be sent</td> </tr> <tr> <td>Accept-Encoding</td> <td>Notify the server of the data compression format that can be sent</td> </tr> <tr> <td>Accept-Language</td> <td>Notify the server that it can send Language</td> </tr> </tbody> </table> <p><img alt="" height="454" src="//i2.wp.com/img-blog.csdnimg.cn/90aa6a20b9314b9685059900e9401cb7.png" width="879"></p> </blockquote> <blockquote> <h3><strong>2. Response message</strong></h3> <p><strong>Status line</strong>: The status line consists of three parts: <strong>protocol version, status code, and status code description</strong>.<br /><strong>Response header</strong>: <strong>Meta information of key-value type</strong>. The response header is similar to the request header, adding some additional information to the response message.<br /> Blank line: There will be a blank line at the end of the response header, indicating the end of the response header.<br /><strong>Response body</strong>: The server <strong>returns the corresponding HTML data</strong>, and the browser displays the page after parsing it.</p> <table border="1" cellpadding="1" cellspacing="1" style="width:650px;"> <thead> <tr> <th>Response Header</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>Server </td> <td>Name and version of server application software</td> </tr> <tr> <td>Content-Type</td> <td>Type of response body (image or binary string)</td> </tr> <tr> <td>Content-Length</td> <td>Response body length</td> </tr> <tr> <td>Content-Charset </td> <td>Encoding used for response body</td> </tr> <tr> <td>Content-Encoding </td> <td>Response body The data compression format used</td> </tr> <tr> <td>Content-Language </td> <td>The language used in the response body</td> </tr> </tbody> </table> <p><img alt="" height="323" src="//i2.wp.com/img-blog.csdnimg.cn/68219c8451c14c41877acd830ab33d3a.png" width="658"></p> <p><center></center></p> </blockquote> </blockquote> </div> </div><!-- .entry-content --> <footer class="entry-footer"> <span class="tags-links">Tagged <a href="https://syntaxbug.com/tag/dns/" rel="tag">dns</a>, <a href="https://syntaxbug.com/tag/html/" rel="tag">html</a>, <a href="https://syntaxbug.com/tag/http/" rel="tag">http</a>, <a href="https://syntaxbug.com/tag/linux/" rel="tag">linux</a>, <a href="https://syntaxbug.com/tag/service/" rel="tag">service</a>, <a href="https://syntaxbug.com/tag/web/" rel="tag">web</a></span> </footer><!-- .entry-footer --> </article><!-- #post-60578 --> <nav class="navigation post-navigation" role="navigation"> <h2 class="screen-reader-text">Post navigation</h2> <div class="nav-links"><div class="nav-previous"><a href="https://syntaxbug.com/a5e7e081db/" rel="prev">Parallel programming|A PySpark multi-process programming practice</a></div><div class="nav-next"><a href="https://syntaxbug.com/e745a55eb9/" rel="next">Go development practice: teach you how to build a login function</a></div></div> </nav> </main><!-- #main --> </div><!-- #primary --> <aside id="secondary" class="widget-area col-sm-4"> <div id="search-2" class="widget widget_search"> <form role="search" method="get" class="search-form" action="https://syntaxbug.com/"> <div class="input-group"> <span class="input-group-addon"><i class="fa fa-search"></i></span> <input type="search" class="search-field form-control" placeholder="Search …" value="" name="s" /> <span class="input-group-btn"> <button class="btn btn-primary search-submit" type="submit">Search</button> </span> </div> </form></div> <div id="recent-posts-2" class="widget widget_recent_entries"> <h3 class="widget-title">Recent Posts</h3> <ul> <li> <a href="https://syntaxbug.com/57135e684b/">JSDoc, an alternative to TypeScript?</a> </li> <li> <a href="https://syntaxbug.com/65a6ec3938/">What channels can Python use to receive orders?</a> </li> <li> <a href="https://syntaxbug.com/c7f8f61d81/">ADO interface _RecordsetPtr pointer</a> </li> <li> <a href="https://syntaxbug.com/3c8a7c1f35/">Unity game development–Behavior tree (Part 2)</a> </li> <li> <a href="https://syntaxbug.com/d0626f740d/">Create efficient Python backend projects: you can’t miss these tools</a> </li> <li> <a href="https://syntaxbug.com/1d42e7327e/">Classification prediction of probabilistic neural network PNN based on cuckoo algorithm optimization – code attached</a> </li> <li> <a href="https://syntaxbug.com/3d05442eb4/">HikariCP connection pool: Possibly consider using a shorter maxLifetime value.</a> </li> <li> <a href="https://syntaxbug.com/9a64438825/">Detailed explanation of java HashMap source code</a> </li> <li> <a href="https://syntaxbug.com/558593ba14/">Android drag and drop startDragAndDrop drag and drop Glide to flexibly load stacked rounded corners, Kotlin (6)</a> </li> <li> <a href="https://syntaxbug.com/e11254af61/">Qt Drag&DropDrag and place</a> </li> <li> <a href="https://syntaxbug.com/bc655f3f79/">jsp+servlet hospital appointment registration system based on javaweb+mysql (java+jdbc+jsp+mysql+ajax)</a> </li> <li> <a href="https://syntaxbug.com/6e1ad9fbfb/">k8s custom Endpoint implements internal pod access to external applications</a> </li> <li> <a href="https://syntaxbug.com/8af302413b/">MySQL Backup and Recovery: Protecting Data Security and Business Continuity</a> </li> <li> <a href="https://syntaxbug.com/6d4c2a5546/">[milkv] 2. Add and test mpu6050 driver</a> </li> <li> <a href="https://syntaxbug.com/fde4afbea8/">[milkv] 1. Light sensor bh1750 driver addition and testing</a> </li> </ul> </div></aside><!-- #secondary --> </div><!-- .row --> </div><!-- #content --> <footer id="colophon" class="site-footer"> <div class="container"> <div class="site-info"> <div class="pull-right"> syntaxbug.com © 2021 All Rights Reserved. </div><!-- .pull-right --> </div><!-- .site-info --> </div><!-- .container --> </footer><!-- #colophon --> </div><!-- #page --> <div class="empty-node hidden"></div><script type='text/javascript'> var codePrettifyLoaderBaseUrl = "https:\/\/syntaxbug.com\/wp-content\/plugins\/code-prettify\/prettify"; </script> <script type='text/javascript' src='https://syntaxbug.com/wp-content/plugins/code-prettify/prettify/run_prettify.js?ver=1.4.0'></script> <script type='text/javascript' src='https://syntaxbug.com/wp-content/themes/bestblogger/vendor/bootstrap/js/bootstrap.min.js?ver=5.0'></script> <script type='text/javascript' src='https://syntaxbug.com/wp-content/themes/bestblogger/js/navigation.js?ver=20151215'></script> <script type='text/javascript' src='https://syntaxbug.com/wp-content/themes/bestblogger/js/skip-link-focus-fix.js?ver=20151215'></script> <script type='text/javascript' src='https://syntaxbug.com/wp-includes/js/comment-reply.min.js?ver=5.0'></script> <script type='text/javascript' src='https://syntaxbug.com/wp-content/themes/bestblogger/js/script.js?ver=5.0'></script> <script type='text/javascript' src='https://syntaxbug.com/wp-includes/js/wp-embed.min.js?ver=5.0'></script> </body> </html>