Java Network socket Programming (vi) HTTP request/Response message __ Programming

Source: Internet
Author: User
Tags response code
The HTTP message contains 2 kinds of messages including the request message and the response message, they all contain the starting line, the first field, and the main body three parts. The request message contains the HTTP message bit request sent by the client when requesting resources from the server, and the response message is sent to the client from the server side. Since their message is very similar, the following is a brief introduction to the three parts of the message: 1. The first line of the starting line message is the starting line, which is used in the request message to indicate what to do and what happens in the response message. 2. The first field has 0 or more header fields after the start line. Each header field contains a name and a value, separated by a colon for ease of parsing. The header ends with a blank line. Adding a header field is as simple as adding a new line. 3. after the main blank line is the optional message body, which contains all types of data. The request body contains data to be sent as a Web server, and the response body crashes the data to be returned to the client. The starting row and header are both textual and structured and, unlike the main body, can contain arbitrary binary data (such as pictures, videos, audio, and so on). You can, of course, include text. The following diagram depicts a complete request-response flowchart that describes the process of a complete client request http://www.joes-hardware.com/tools.html resource, where the start line in the request message contains the requested method get, The relative location of the requested resource, the version of the Protocol, and so on. The request header consists mainly of the HTTP protocol version that describes the client browser version, the request server host, the client receives text format, the received language setting, and so on, and the response message contains: The response line contains a response in the reply to the file, the server returns the status code, the status value three parts The response header contains the server response time, the Web server version, the modification time, the type of response text, and so on the response body contains the text content that the client wants to display the following illustration of the response code:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.