HTTP (Hyper Text Transfer Protocol is an abbreviation for hypertext transfer protocol, which is used to transmit data of WWW mode. The HTTP protocol adopted the request / response model. The client sends a request to the server, the request header contains the requested method, the URI, the protocol version, and the message structure that contains the request modifier, customer information, and content is similar to MIME. The server acts in a state line as a response, and the corresponding content includes the version of the message protocol, successful or error encoding plus the content containing server information, physical meta information, and possible entity. Typically HTTP messages include a client's request message and a server response message to the client. These two types of messages consist of one starting line, one or more headers, one of the empty rows and optional messomals that are only ended. HTTP's headbands include universal heads, request heads, four parts: heads and entities. Each headband consists of a domain name, a colon (:), and domain value. The domain name is case-sensitive, and any number of spaces can be added before the domain value can be expanded to multi-line, and at least one space or tab is used at the beginning of each row. The following is a brief introduction to the request head and response to the HTTP protocol, which will help you learn more about some test tools to record the principle of the script, which makes it easy to edit the performance test script. The request header and responses will be explained by examples. Request Message: Post /bbs/login2.asp?action=chk http / 1.1accept: image / gif, image / x-xbitmap, image / jpeg, image / pjpeg, application / vnd.ms-excel, application / vnd. ms-powerpoint, application / msword, application / x-shockwave-flash, * / * Referer: http://127.0.0.1/inpage.aspAccept-Language: zh-cnContent-Type: application / x-www-form-urlencodedAccept -Encoding: gzip, deflateUser-Agent: Mozilla / 4.0 (compatible; MSIE 6.0; Windows NT 5.0; (R1 1.3)) Host: 127.0.0.1Content-Length: 69Connection: Keep-AliveCache-Control: no-cacheCookie: aspsky = StatUserID = 2200878793; Cookie1 = y; ASPSESSIONIDQQTBSRCB = BHHIOGHAGFCKKNCGLLHDFHBMusername = snappyboy & CookieDate = 0 & password = 123456 & Submit3 =% B5% C7% C2% BC acts first request message in the following format:
Method Request-Uri http-version crlf, for example: post /bbs/login2.asp?action=chk http / 1.1
Method represents the method completed for Request-URI, this field is sensitive, including options, Get, Head, POST, PUT, DELETE, TRACE. Methods GET and HEAD should be supported by all general web servers, and all other methods are optional. The GET method retrieves information identified by the request-URI. The HEAD method is also the information identified by the request-URI, just when the message can be returned when responding. The POST method can request the server to receive entity information contained in the request, which can be used to submit a form, send a message to the newsgroup, BBS, mail group, and database.
Request-URI follows the URI format, when this field is asterisk (*), the description request is not used for a particular resource address, but for the server itself. HTTP-VERSION represents the supported HTTP version, for example, HTTP / 1.1.
CRLF indicates a wrap-in return. The request header allows the client to pass additional information about the request or about the client to the server. The request header may contain the following field accept, accept-charse, accept-encoding, accept-language, authorization, from, host, if-modified-since, if-match, if-none-match, if-range, if-range , IF-unmodified-Since, Max-Forwards, Proxy-Authorization, Range, Referer, User-Agent. The extended demand for the request header requires both parties to support. If there is an unsupported request header domain, it will generally be processed as an entity header domain.
The Host Skecess Headfielder domain specifies the INTENET host and port number of the request resource, and must represent the position of the original server or gateway requesting the URL. The HTTP / 1.1 request must contain the host header field, otherwise the system will return in a 400 state code.
The Referer header domain The Referr head field allows the client to specify the source resource address requested URI, which allows the server to generate a back chain table, which can be used to log in, optimize Cache. He also allows the abolition or wrong connection to be tracked for maintenance purposes. If the requested URI does not have its own URI address, Referr cannot be sent. If specified is a partial URI address, this address should be a relative address.
The Range header domain can request one or more sub-ranges of the entity. For example, a head 500 byte: Bytes = 0 - 499 Represents the second 500 bytes: bytes = 500 - 999 Indicates the last 500 bytes: Bytes = -500 Represents the range after 500 bytes: bytes = 500- The first and last bytes: bytes = 0-0, -1 specify several scope: BYTES = 500-600, 601-999 But the server can ignore this request header, if the unconditional Get contains the Range request head, the response will Returning in status code 206 (Partial Content) instead of 200 (OK).
The user-agent header domain User-Agent header contains the user information that issues a request. Cache-Control header (request and answering universal header) cache-control Specifies the cache mechanism that follows the request and response. Setting Cache-Control in the request message or response message does not modify the cache processing process during another message processing. The cache instructions when requested include NO-CACHE, NO-Store, Max-Age, Max-Stale, Min-Fresh, ONLY-IF-CACHED, and the instructions in the response message include public, private, no-cache, no-store, NO-Transform, Must-REVALIDATE, PROXY-REVALIDATE, MAX-AGE. The instructions in each message are as follows: public indicates that the response can be cached by any cache area. Private Indicates the entire or partial response message for a single user, cannot be shared cache processing. This allows the server to only describe only the partial response message of the user, this response message is invalid for the request of other users. NO-Cache Indicates the request or response message cannot cache the NO-Store to prevent important information from being unintentionally published. Sending in the request message will make the request and response messages do not use the cache. The MAX-AGE indicates that the client can receive the response of the survival period is not greater than the specified time (in seconds). MIN-FRESH indicates that the client can receive a response time than the current time plus the specified time response. Max-Stale indicates that the client can receive a response message exceeded timeout period. If the value of the Max-Stale message is specified, the client can receive a response message exceeding the specified value of the period. Answering Message: http / 1.1 200 OKServer: Microsoft-IIS / 5.0Date: Sat, 15 Jan 2005 15:36:26 Gmtcontent-Length: 31401Content-Type: Text / HTMLCACHE-Control: Private
omission body> html> The first behavior of the response message The following format: http-version status-code reason-phrase crlfhttp-version represents the supported HTTP version, for example HTTP / 1.1. Status-code is a three-digit result code. Reason-phrase provides a simple text description to Status-Code. Status-code is mainly used for automatic machine automatic identification, and REASON-Phrase is mainly used to help users understand. The first numeric definition response of Status-Code, the latter two numbers have no classification. The first number may take 5 different values: 1xx: Information response class, indicating that the request is received and continues to process 2xx: processing success response class, indicating that the action is successfully received, understood, and accept 3xx: redirect response class, to complete The specified action must be accepted further 4xx: client error, customer requests include syntax errors or do not perform 5xx: server error, server does not perform a correct request correctlyThe response header field allows the server to pass the additional information of the status line, which mainly describes the information of the server and further information of the request-URI. The response header contains AGE, LOCATION, Proxy-Authenticate, Public, Retry -After, Server, Vary, Warning, WWW-Authenticate. The extension of the response header domain requires both communication, if there is an unsupported response header domain, it will generally be processed as an entity header domain.
The Location Respondent head Location response head is used to redirect the recipient to a new URI address.
The Server responding to the head server response header contains software information of the original server for processing the request. This domain can contain multiple product identifications and comments, and the product identity is generally sorted according to importance.
Entity request messages and response messages can include entity information, and physical information is typically composed of physical headers and entities. The physical head domain contains the original information about the entity, including allow, content-base, content-encoding, content-language, content-length, content-location, content-md5, content-range, Content-Type, ETAG, Expires , Last-Modified, Extension-Herder. Extension-Header allows the client to define a new entity head, but these domains may not be able to recognize unconduct. The entity can be a coded byte stream, which is defined by content-encoding or content-type, which is defined by Content-length or Content-Range. The Content-Type entity first-type entity head is used to indicate the media type of the entity to the receiver, specify the entity medium type of the receiver to the receiver, or the request medium type Content-Range entity on the GET method.
The Content-Range entity is used to specify a part of the insertion position in the entire entity, and he also indicates the length of the entire entity. Returning a partial response to the client, it must describe the range of the response and the length of the entire entity. General format:
Content-Range: BYTES-Unit SP First-Byte-Pos -Last-Byte-POS / Entity-Legth, for example, the form of the transfer head 500 word segment: Content-Range: BYTES 0-499 / 1234 If an HTTP message Contains this section (for example, the response to the range request or overlap request for a range of ranges), the content-range represents the range of the transmitted, and the content-length represents the number of bytes actually transmitted.
Last-Modified Entity First Last-Modified Entity First Specifies the last revision time of the saved content on the server. How do I get this information? There are many tools to get this information, on the one hand, you can use script recording tools, such as WAS, LoadRunner, Jmeter, etc., but they must be recorded through the browser (for the web protocol part). It can also detect the activity of the HTTP protocol by means of network interception software. I use Visual Sniffer (which is used to intercept the TCP / IP / UDP / ICMP of TCP / IP / UDP / ICMP through the network), which can be monitored Data interacting with the HTTP protocol using the unit. Most of this article take the relevant professional website, and pick it here. I think that the most useful part of the actual work is introduced to everyone. If you are interested, you can also check the relevant information.