Hypertext Transfer Protocol and HTTP Package

xiaoxiao2021-03-30  201

The HTTP protocol is used to send and receive messages on the Internet. The HTTP protocol is a request-to-answer protocol-client sends a request, the server returns the response of the request, and all requests and answers are HTTP packages. The HTTP protocol uses a reliable TCP connection, and the default port is 80. The first version of HTTP is http / 0.9, and later developed to HTTP / 1.0, and now the latest version is HTTP / 1.1. HTTP / 1.1 is defined by RFC 2616. In HTTP, the session between Client / Server is always initialized by the client by establishing a connection and sending an HTTP request package, the server does not actively contact the client or requires connection to the client. Browsers and servers can interrupt the connection at any time, for example, when browsing the web, you can click the "Stop" button to interrupt the current file download process, turn off the HTTP connection with the web server. 1 HTTP Request Packet HTTP Request Packet (GET, POST, etc.) consists of three parts, namely: method -uri-protocol / version, request head, request body. Below is an example of an HTTP request package (GET):

Get /index.jsp http / 1.1

Accept-language: zh-cn

Connection: Keep-alive

Host: 192.168.0.106

Content-Length: 37

UserName = new_andy & password = new_andy

The first line of the request package is the method -uri-protocol / version: GET is the request method, according to the HTTP standard, the HTTP request can use a variety of request methods. HTTP 1.1 supports seven request methods: GET, POST, HEAD, OPTIONS, PUT, DELETE, and TRACE, etc., commonly used for requesting methods GET and POST. /index.jsp represents the URI. URI specifies the network resources to access. HTTP / 1.1 is the version of the agreement and protocol. The last line Username = new_andy & password = new_andy is the body, and the body is separated from the HTTP header. Here, you need to explain, where content-length illustrates the length of the body, and some body lengths are not described in the header, just indicate Transfer-Encoding: chunked. See RFC 1626 about the length calculation method of the chunked type. The header of the request package will also contain a lot of useful information about the client environment and the request text, which is no longer described. 2 The HTTP response package and HTTP request package are similar, consisting of three parts, respectively: protocol - status code - description, response, response body. Below is an example of an HTTP response:

HTTP / 1.1 200 ok

Server: Microsoft-IIS / 4.0

Date: Mon, 3 Jan 2005 13:13:33 GMT

Content-Type: Text / HTML

Last-Modified: Mon, 11 Jan 2004 13:23:42 GMT

Content-Length: 90

Interpretation of HTTP Packets </ Title> </ head> <body></p> <p>Hello World!</p> <p></ body></p> <p></ html></p> <p>The first line of the HTTP response package is similar to the first line of the HTTP request, indicating that the protocol used is HTTP 1.1, and the server processing requested status code 200. The response should also contain many useful information as the request head, such as server type, datetime, content type, and length. The body of the response is the HTML page returned by the server. The response head and the body are also separated by CRLF. Explanation in Wiki</p> <p>Hypertext Transfer Protocol (HTTP, Hypertext Transfer Protocol) is the most widely used network transport protocol on the Internet. All WWW files must be observed. Design HTTP initial purpose is to provide a method of publishing and receiving an HTML page.</p> <p>Overview</p> <p>The development of HTTP is the result of the World Wide Web Association and the Internet Working Group, which determines the final version in a series of RFC releases, where the most famous is RFC 2616. HTTP / 1.1 is defined in RFC 2616 This version of the generally used today.</p> <p>HTTP is a protocol for requests and answers between clients and servers. An HTTP client, such as a web browser, initializes a request by establishing a connection to a remote host special port (default port 80). An HTTP server sends a request sequence by listening to a special port waiting for the client, just like "get / http / 1.1" (used to request the default page of the web server), select the same MIME message like Email, this message is included in this message A large number of information head sequences for requesting all aspects, responding to a selected reserved data body. After receiving a request sequence (if necessary, if there is a message), the server will send back a reply message, such as "200 ok", send back a message, this message may be the requested file, Error message or some other information.</p> <p>HTTP is different from other TCP-based protocols such as FTP. In HTTP, once a special request (or the relevant sequence of requests) is complete, the connection is usually interrupted. This design makes the HTTP is perfect for the current page to connect to another server page to another server page. When the lack of persistent connection is a necessary choice for maintaining the user status, it will accidentally generate some problems for web designers. Most of these methods include the use of "cookies".</p> <p>Here, there is a security version of HTTP is called HTTPS, HTTPS supports any encryption algorithm, as long as this encryption algorithm can be understood by both parties.</p> <p>HTTP (and HTTPS) is located by a unique resource locator or a referred to as URLS. Creating the syntax of this address location for HTML links.</p> <p>example</p> <p>Below is an example of a session between an HTTP client and a server, running at www.google.com, port 80</p> <p>Client request:</p> <p>Get / http / 1.1host: www.google.com</p> <p>(Following a wrap, realizing the carriage return)</p> <p>Server Answer:</p> <p>HTTP / 1.1 200 OKContent-Length: 3059Server: GWS / 2.0Date: Sat, 11 Jan 2003 02:44:04 GMTContent-Type: text / htmlCache-control: privateSet-Cookie: PREF = ID = 73d4aef52e57bae9: TM = 1042253044: LM = 1042253044: S = SMCC_HRPCQIQYX9J; Expires = Sun, 17-JAN-2038 19:14:07 gmt; path = /; domain = .google.comconnection: Keep-Alive</p> <p>(Followed by an empty line, and the text of the HTML format consists of Google's homepage) In HTTP 1.0, the client sends a request to the server, and the server sends a response to the client. Thereafter, the connection will be released. On the other hand, HTTP 1.1 supports persistent connections. This allows the client to send a request and receive a response, and then quickly sends another request and receive another response. Because of multiple additional requests, the TCP connection is not released, and each request is relatively small about TCP load. At the same time, it is possible to send multiple requests (usually two) before obtaining a response from the previous request. This technology is called "pipeline".</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-130554.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="130554" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.037</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = 'HRBBWrLdOJdiM_2FlGUT7lGnWwE1TXb_2F1wDpdEZGGAI148noXzeZuHD515tlI5aqBzLJnJJooxLbLXico3e6hygw_3D_3D'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>