http protocol (ii) request and response packets constituting the http protocol (ii) request and response packets constituting

http protocol (ii) request and response packets constituting

 

One party to the http protocol for communication between the client and the server to request access to a resource is called the client and server resources in response to the called side.

Here is a simple process of communication between the client and server

PS: The request must establish communications from the client, the server does not send a response before the receipt of the request

First is that the constitution following request:

1) Method Request URI Protocol / version 

2) request header (Request Header) 

3) request body

The following is an example of a request:

GET/sample.jspHTTP/1.1

Accept:image/gif.image/jpeg,*/*

Accept-Language:zh-cn

Connection:Keep-Alive

Host:localhost

User-Agent:Mozila/4.0(compatible;MSIE5.01;Window NT5.0)

Accept-Encoding:gzip,deflate

username=jinqiao&password=1234

1) Method Request URI Protocol / version

In "the above requests GET" request of a representative method, " /sample.jsp" represents the URI, " the HTTP / 1.1 protocol and protocol version representatives.

According to the HTTP standard, HTTP request can use several request methods. Specific methods and differences behind us.

2) request header

Accept the acceptable content type
Accept-Language language
Connection connection status
Host requested domain name (here I set the local request, of course, the domain name, the so-called URL)
User-Agent browser browser type and version
Accept-Encoding pharmaceutically compression type gzip, deflate
 
3) request body

Request header and the request is a blank line between the text that represents the head request has ended, then the request body. The request body can contain query strings customer submissions:

username=jinqiao&password=1234

In the above example , the body of the request is only a single line. Of course, in practical applications, the HTTP request body may comprise more content.

 
Configuration response

HTTP response to the HTTP request similar to, HTTP response made also composed of three parts:

1) Status line

2) response header

3) the response body

After receiving and interpreting a request message, the server returns a HTTP response message.

Status line by the protocol version, status codes in digital form, and the corresponding state description, separated by a space between elements.

格式:    HTTP-Version Status-Code Reason-Phrase CRLF

For example : HTTP / 1.1 200 OK 

 

Status Code:

Status code of three digits, indicating whether the request is satisfied or understood.

status description:

Status Description provides a brief text description about the status codes.

The first digit of the status code defines the response category, followed by two no specific classification.

The first number has five possible values:

- 1xx: indication information - indicates a request has been received, processing continues.

- 2xx: Success - indicates that the request has been successfully received, understood, accepted.

- 3xx: Redirection - to fulfill the request must go a step further.

- 4xx: Client Error - The request contains a syntax error or a request can not be achieved.

- 5xx: Server-side Error - The server failed to achieve a legitimate request.

Description Status Code Status     Description

  200 OK successful client requests

  400 Bad Request Due to client requests a syntax error, it can not be understood by the server.

  401 Unauthonzed unauthorized request. This status code must be used with the WWW-Authenticate header field

  403 Forbidden server receives the request, but refused to provide services. Server will usually give reasons for not providing services in the response body

  404 Not Found requested resource does not exist, for example, entered the wrong URL.

  500 Internal Server Error server unexpected error occurred, making it impossible to complete the client's request.

  503 Service Unavailable The server is currently unable to handle the client's request, after a period of time, the server might return to normal.

 

Response header

Response header may include: 

Location: in response to a recipient header field for redirecting to a new location.

Server: response header field contains information server software for processing the request. It User-Agent request header field is corresponding to the former transmission information server software, which sends the client software (browser ), and operating systems.

Content-Encoding: entity header field is used as a media type modifier that indicates the value of the additional content coding has been applied to the entity body, and thus to obtain the media type of the referenced Content- Type header field, to employ the appropriate the decoding mechanism.

Content-Language: entity header field describes the natural language resources used. Content-Language allows users to follow their preferred language to identify and differentiate entities. 

Content-Length: length entity header field specified for text, decimal bytes stored to represent, a numeric character is one byte, with its corresponding ASCII code storage transmission.

Note that: This is an entity body length only the length, not including the length of the entity header.

Content-Type: The term entity header field indicates the media type sent to the entity body of a recipient.

Last-Modified: header field is used to indicate the entity of resources last modification date and time.

Expires: the entity header field gives the date and time response expired.

Expires entity header fields date and time must be the date in the format RFC 1123, for example:

Expires: Thu, 15 Sep 2005 16:00:00 GMT

The following is an example HTTP response:

HTTP/1.1 200 OK

 

Server:Apache Tomcat/5.0.12

Date:Mon,6Oct2003 13:23:42 GMT

Content-Length:112

From the above examples we can to shining for comparison, or they can try it on your computer, here to teach you a method:
Using the chrome browser that comes with developer tools see http header method
1. Right-click anywhere on the page and select Inspect Element or press shift + ctrl + c, or F12, open chrome built-in debugging tools;
2. Select the network label, refresh the page (refresh in the open debugging tools);
3. Refresh the page to find the url on the left, click to select the right headers, you can see http requests and responses of the current page
 
 
PS: About the request and response header field, the more due to the current provisions of the http protocol, not list them here, and interested can Baidu under specific http header fields. . .
 
 
 
 

One party to the http protocol for communication between the client and the server to request access to a resource is called the client and server resources in response to the called side.

Here is a simple process of communication between the client and server

PS: The request must establish communications from the client, the server does not send a response before the receipt of the request

First is that the constitution following request:

1) Method Request URI Protocol / version 

2) request header (Request Header) 

3) request body

The following is an example of a request:

GET/sample.jspHTTP/1.1

Accept:image/gif.image/jpeg,*/*

Accept-Language:zh-cn

Connection:Keep-Alive

Host:localhost

User-Agent:Mozila/4.0(compatible;MSIE5.01;Window NT5.0)

Accept-Encoding:gzip,deflate

username=jinqiao&password=1234

1) Method Request URI Protocol / version

In "the above requests GET" request of a representative method, " /sample.jsp" represents the URI, " the HTTP / 1.1 protocol and protocol version representatives.

According to the HTTP standard, HTTP request can use several request methods. Specific methods and differences behind us.

2) request header

Accept the acceptable content type
Accept-Language language
Connection connection status
Host requested domain name (here I set the local request, of course, the domain name, the so-called URL)
User-Agent browser browser type and version
Accept-Encoding pharmaceutically compression type gzip, deflate
 
3) request body

Request header and the request is a blank line between the text that represents the head request has ended, then the request body. The request body can contain query strings customer submissions:

username=jinqiao&password=1234

In the above example , the body of the request is only a single line. Of course, in practical applications, the HTTP request body may comprise more content.

 
Configuration response

HTTP response to the HTTP request similar to, HTTP response made also composed of three parts:

1) Status line

2) response header

3) the response body

After receiving and interpreting a request message, the server returns a HTTP response message.

Status line by the protocol version, status codes in digital form, and the corresponding state description, separated by a space between elements.

格式:    HTTP-Version Status-Code Reason-Phrase CRLF

For example : HTTP / 1.1 200 OK 

 

Status Code:

Status code of three digits, indicating whether the request is satisfied or understood.

status description:

Status Description provides a brief text description about the status codes.

The first digit of the status code defines the response category, followed by two no specific classification.

The first number has five possible values:

- 1xx: indication information - indicates a request has been received, processing continues.

- 2xx: Success - indicates that the request has been successfully received, understood, accepted.

- 3xx: Redirection - to fulfill the request must go a step further.

- 4xx: Client Error - The request contains a syntax error or a request can not be achieved.

- 5xx: Server-side Error - The server failed to achieve a legitimate request.

Description Status Code Status     Description

  200 OK successful client requests

  400 Bad Request Due to client requests a syntax error, it can not be understood by the server.

  401 Unauthonzed unauthorized request. This status code must be used with the WWW-Authenticate header field

  403 Forbidden server receives the request, but refused to provide services. Server will usually give reasons for not providing services in the response body

  404 Not Found requested resource does not exist, for example, entered the wrong URL.

  500 Internal Server Error server unexpected error occurred, making it impossible to complete the client's request.

  503 Service Unavailable The server is currently unable to handle the client's request, after a period of time, the server might return to normal.

 

Response header

Response header may include: 

Location: in response to a recipient header field for redirecting to a new location.

Server: response header field contains information server software for processing the request. It User-Agent request header field is corresponding to the former transmission information server software, which sends the client software (browser ), and operating systems.

Content-Encoding: entity header field is used as a media type modifier that indicates the value of the additional content coding has been applied to the entity body, and thus to obtain the media type of the referenced Content- Type header field, to employ the appropriate the decoding mechanism.

Content-Language: entity header field describes the natural language resources used. Content-Language allows users to follow their preferred language to identify and differentiate entities. 

Content-Length: length entity header field specified for text, decimal bytes stored to represent, a numeric character is one byte, with its corresponding ASCII code storage transmission.

Note that: This is an entity body length only the length, not including the length of the entity header.

Content-Type: The term entity header field indicates the media type sent to the entity body of a recipient.

Last-Modified: header field is used to indicate the entity of resources last modification date and time.

Expires: the entity header field gives the date and time response expired.

Expires entity header fields date and time must be the date in the format RFC 1123, for example:

Expires: Thu, 15 Sep 2005 16:00:00 GMT

The following is an example HTTP response:

HTTP/1.1 200 OK

 

Server:Apache Tomcat/5.0.12

Date:Mon,6Oct2003 13:23:42 GMT

Content-Length:112

From the above examples we can to shining for comparison, or they can try it on your computer, here to teach you a method:
Using the chrome browser that comes with developer tools see http header method
1. Right-click anywhere on the page and select Inspect Element or press shift + ctrl + c, or F12, open chrome built-in debugging tools;
2. Select the network label, refresh the page (refresh in the open debugging tools);
3. Refresh the page to find the url on the left, click to select the right headers, you can see http requests and responses of the current page
 
 
PS: About the request and response header field, the more due to the current provisions of the http protocol, not list them here, and interested can Baidu under specific http header fields. . .
 
 
 
 

Guess you like

Origin www.cnblogs.com/zhengyao9236/p/11583654.html