In-depth analysis of HTTP protocol
http Introductionhttp The request part of http Basic structure of requestRequest lineDetailed explanation HTTP request headerHttp Response detailshttp Basic structure of responseStatus linehttp Detailed explanation of response message headerExpires, Pragma, Cache-Control Set not to cacheExpires, Pragma, Cache-Control Settings Specify cache timeHTTP Request details——General information header
http introduction
http protocol is based on tcp/ip protocol
http protocol full name Hypertext Transfer Protocol ( HTTP,HyperText Transfer Protocol)
http protocol version 1.0 1.1 2.0
-
http 1.0 becomes a short connection, http 1.1 is called a long connection
The so-called long and short refers to the long connection lasting 1.1 30s and the short connection being disconnected immediately after sending the data
-
Http defines different methods for interacting with the server. There are four basic methods, namely GET, POST, PUT, and DELETE. The full name of URL is resource descriptor. We can think of it this way: a URL address, which is used to describe a resource on the network, and GET, POST, PUT, and DELETE in HTTP correspond to the search and modification of this resource. Add and delete 4 operations. At this point, everyone should have a general understanding. GET is generally used to obtain/query resource information, while POST is generally used to update resource information.
#The request part of http
Basic structure of http request
Request line
Message header
A blank line
## Content
Request lineRequest methods include: post, get, options, delete, trace, put
Commonly used ones are: post, get
The difference between post and get: GET uses URL or Cookie to pass parameters. And POST puts the data in BODY. The GET URL will have a length limit, and the POST data can be very large. POST is safer than GET because the data is not visible on the address bar. Accept: Tell the server the files I can accept Type MIME types acceptable to the browser Accept-Charset: Character set encoding acceptable to the browser Accept-Encoding: Can accept compressed data in a certain format such as: gzip, compress. The data encoding method that the browser can decode Accept-Langage: The language supported by the browser Host: Indicates who the host I am looking for is ## If-Wodified-Since: Tell the server whether there is a file to be requested in the local cache that contains the time of the requested file // The server receives this request and compares the time to determine whether the file requested by the browser has changed. If Changes will send a new file to the browser. The data will not be sent again without changes. //Note: It will only be returned if the requested content has been modified after the specified date, otherwise 304"Not will be returned.
Modified" response. Referer: Tell the server where I am from. This message header is often used to prevent hot links. My personal understanding on how to prevent hotlinking: Hotlinking: Hotlinking means that the service provider itself does not provide services Content, bypassing other beneficial end-user interfaces (such as advertisements) through technical means, directly providing service content of other service providers to end-users on their own websites, defrauding end-users’ browsing and click-through rates. No beneficiaries. Providing resources or providing few resources without any benefit to the real service provider ## The value of the referer is what you click on the connection file. Location. referer.startWith("Internal Path"); ##Connection: Indicates whether a persistent connection is required. If the Servlet sees that the value here is "Keep-Alive", or see Since the request uses HTTP 1.1 (HTTP 1.1 uses persistent connections by default), it can take advantage of persistent connections and significantly reduce the download time when the page contains multiple elements (such as Applets, images). At this point, the Servlet needs to send a Content-Length header in the response. The simplest way to implement it is: first write the content
ByteArrayOutputStream and then calculates its size before actually writing out the contents. Date: The time when the browser sent the http request. Content-Length: Indicates the length of the request message body. ##UA-Pixels, UA-Color, UA-OS, UA-CPU: Sent by some versions of IE browser Non-standard request headers indicating screen size, color depth, operating system and CPU type. ## Status line Multiple headers One blank line Entity content ##Status line Format: http version number status code reason description The status code is used to indicate the server's processing result of the request. It is a three-dimensional decimal number. Response status codes are divided into 5 categories. Location:让浏览器重新定位到 指定的 URL Server:告诉浏览器 服务器的类型 Content-Encoding:服务端能够发送压缩编码类型 Content-Length: 服务器端发送的压缩数据的长度 Content-Langage:服务端发送的语言类型 Content-Type:服务端发送的类型及采用的编码方式 Last-Modified:服务端对该资源最后的修改(更新)时间 Refresh:服务端要求浏览器在指定的时间,刷新,然后访问指定的页面路径 Content-Disposition:attachmen;filename=aaa.zip 服务端要求客户端一下载文件的方式打开该文件,即告诉浏览器有文件需要下载 Transfer-Encoding:传送数据到客户端的方式 Set-Cookie:服务端发送到客户端的暂存数据 Cache-Control:告诉浏览器如何缓存页面数据 Expires:告诉浏览器如何缓存页面数据 参数 -1 不缓存 Pragma:告诉浏览器如何缓存页面数据 Connection:维护客户端和服务端的连接关系 是否保持连接 Date:服务端响应客户端的时间
通用信息头指既能用于请求,又能用于响应的一些消息头 Cache-Control:no-cache Pragma:no-cache Connection:close/Keep-Alive Date:Tue,。。。 The above is the detailed content of In-depth analysis of HTTP protocol. For more information, please follow other related articles on the PHP Chinese website! AI-powered app for creating realistic nude photos Online AI tool for removing clothes from photos. Undress images for free AI clothes remover Swap faces in any video effortlessly with our completely free AI face swap tool! Easy-to-use and free code editor Chinese version, very easy to use Powerful PHP integrated development environment Visual web development tools God-level code editing software (SublimeText3) Detailed explanation of Oracle error 3114: How to solve it quickly, specific code examples are needed. During the development and management of Oracle database, we often encounter various errors, among which error 3114 is a relatively common problem. Error 3114 usually indicates a problem with the database connection, which may be caused by network failure, database service stop, or incorrect connection string settings. This article will explain in detail the cause of error 3114 and how to quickly solve this problem, and attach the specific code Wormhole is a leader in blockchain interoperability, focused on creating resilient, future-proof decentralized systems that prioritize ownership, control, and permissionless innovation. The foundation of this vision is a commitment to technical expertise, ethical principles, and community alignment to redefine the interoperability landscape with simplicity, clarity, and a broad suite of multi-chain solutions. With the rise of zero-knowledge proofs, scaling solutions, and feature-rich token standards, blockchains are becoming more powerful and interoperability is becoming increasingly important. In this innovative application environment, novel governance systems and practical capabilities bring unprecedented opportunities to assets across the network. Protocol builders are now grappling with how to operate in this emerging multi-chain [Analysis of the meaning and usage of midpoint in PHP] In PHP, midpoint (.) is a commonly used operator used to connect two strings or properties or methods of objects. In this article, we’ll take a deep dive into the meaning and usage of midpoints in PHP, illustrating them with concrete code examples. 1. Connect string midpoint operator. The most common usage in PHP is to connect two strings. By placing . between two strings, you can splice them together to form a new string. $string1=&qu How to implement HTTP streaming in C++? Create an SSL stream socket using Boost.Asio and the asiohttps client library. Connect to the server and send an HTTP request. Receive HTTP response headers and print them. Receives the HTTP response body and prints it. Due to space limitations, the following is a brief article: Apache2 is a commonly used web server software, and PHP is a widely used server-side scripting language. In the process of building a website, sometimes you encounter the problem that Apache2 cannot correctly parse the PHP file, causing the PHP code to fail to execute. This problem is usually caused by Apache2 not configuring the PHP module correctly, or the PHP module being incompatible with the version of Apache2. There are generally two ways to solve this problem, one is Analysis of new features of Win11: How to skip logging in to a Microsoft account. With the release of Windows 11, many users have found that it brings more convenience and new features. However, some users may not like having their system tied to a Microsoft account and wish to skip this step. This article will introduce some methods to help users skip logging in to a Microsoft account in Windows 11 and achieve a more private and autonomous experience. First, let’s understand why some users are reluctant to log in to their Microsoft account. On the one hand, some users worry that they JSON, Jackson, Gson, data operations, Java introduction jsON (javascript object notation) is a lightweight data exchange format widely used in WEB applications and APIs. Java provides a wealth of libraries to process JSON data, the most popular of which are Jackson and Gson. This article will mainly introduce how to use these two libraries to read, write and modify JSON data. Read JSON data JacksonObjectMappermapper=newObjectMapper();JsonnoderootNode=mapper.readTree(jsonStr);GsonG Introduction XML (Extensible Markup Language) is a popular format for storing and transmitting data. Parsing XML in Java is a necessary task for many applications, from data exchange to document processing. To parse XML efficiently, developers can use various Java libraries. This article will compare some of the most popular XML parsing libraries, focusing on their features, functionality, and performance to help developers make an informed choice. DOM (Document Object Model) parsing library JavaXMLDOMAPI: a standard DOM implementation provided by Oracle. It provides an object model that allows developers to access and manipulate XML documents. DocumentBuilderFactoryfactory=DDetailed explanation of HTTP request headers
public void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException{ // 防止乱码 response.setContentType("text/html;charset=utf-8"); // 获取输出流 PrintWriter out = response.getWriter(); // 获取用户浏览器 Referer String referer = request.getHeader("Referer"); if(referer == null || referer.startsWith("http://localhost:8080/本地内部用户web应用路径")){ response.sendRedirect("其他非真正资源网页"); return; }else{ } // 内部资源文件 。。。。。。。。。。。 }
Http response details
The basic structure of http response
Status code ##Meaning 100~199 indicates that the request was successfully received and the client is required to continue submitting. The entire processing process can be completed only with the next request 200~299 indicates that the request was successfully received and the entire processing process has been completed. Commonly used 200 ##400~ 499##300~399 ## is used to complete the request , the client needs to further refine the request, for example: the requested resource has been moved to a new address, commonly used 302, 307The client's request is incorrect. Commonly used 404 ##500~599 ## appears on the server side Error, commonly used 500 # http 响应消息头详解
Expires、Pragma、Cache-Control 设置不缓存
// 指定该页面不缓存 ie浏览器内核response.setDateHeader("Expires",-1);// 兼容设置response.setHeader("Cache-Control","no-cache");response.setHeader("Pragma","no-cache");
Expires、Pragma、Cache-Control 设置 指定缓存时间
// 指定该页面缓存指定时间 ie浏览器内核response.setDateHeader("Expires",System.currentTimeMillis()*3600*1000*24;
HTTP 请求的细节————通用信息头
Hot AI Tools
Undresser.AI Undress
AI Clothes Remover
Undress AI Tool
Clothoff.io
Video Face Swap
Hot Article
Hot Tools
Notepad++7.3.1
SublimeText3 Chinese version
Zend Studio 13.0.1
Dreamweaver CS6
SublimeText3 Mac version
Hot Topics
1677
14
1431
52
1334
25
1280
29
1257
24
Detailed explanation of Oracle error 3114: How to solve it quickly
Mar 08, 2024 pm 02:42 PM
Parsing Wormhole NTT: an open framework for any Token
Mar 05, 2024 pm 12:46 PM
Analysis of the meaning and usage of midpoint in PHP
Mar 27, 2024 pm 08:57 PM
How to implement HTTP streaming using C++?
May 31, 2024 am 11:06 AM
Apache2 cannot correctly parse PHP files
Mar 08, 2024 am 11:09 AM
Analysis of new features of Win11: How to skip logging in to Microsoft account
Mar 27, 2024 pm 05:24 PM
A Practical Guide to Java JSON Processing: A Data Manipulation Masterclass
Mar 09, 2024 am 09:10 AM
Comparison of Java libraries for XML parsing: Finding the best solution
Mar 09, 2024 am 09:10 AM