HTTP requests (get and post requests) and responses

Source: Internet
Author: User
Tags html header

1. http request

Basic HTTP request format

========================================================== ==============

<Request line> request line

<Headers> Request Header (parameter header)

<Blank line> blank line

[<Request-body>] Request Entity (get does not have Post)

==============================================

1.1 request line:

Located in the first line of the Request Message

Format: Request Method resource path HTTP Version Number <CRLF press ENTER line feed space tab>

Common Request Methods: Get and post

Difference between get and post:

(1) on the client side, the get method submits data through the URL, and the data can be seen in the URL. In the post mode, the data is placed in the HTML header for submission.

(2) a maximum of 1 K data can be submitted in get mode, but not in post mode.

(3) security issues. When get is used, the parameters are displayed in the address bar, which is not secure, whereas post is not displayed, which is safe. If the data is Chinese and non-sensitive, use get. If the data you enter is not Chinese characters and contains sensitive data, use post as well.

(4) idempotence

1.2 parameter header: starting from the second line to the first empty line. Purpose: Send some basic information about the client to the server.


Ii. Http response

Basic HTTP Response format

========================================================== ==============

<Status line> Status line

<Headers> Response Header

[<Request-body>] response entity

==============================================

The only real difference is that the request line is replaced by the Status line in the first row. Status line describes the requested resources by providing a status code.


Status Code Description
100 ~ 199 The request is successfully received, and the client is required to submit the next request to complete the entire process.
200 ~ 299 Indicates that the request is successfully received and the entire process has been completed.
300 ~ 399 To complete the request, the customer needs to further refine the request. For example, the requested resource has moved a new address.
400 ~ 499 Client request Error
500 ~ 599 Server errors


Common status codes:
200 (normal): indicates that everything is normal, and the returned result is a normal request.


302/307 (temporary redirection): indicates that the requested document has been temporarily moved elsewhere. The new URL of this document is provided in the location response header.


304 (not modified): indicates that the Client Cache version is the latest, and the client can continue to use it without sending requests to the server.


404 (not found): no resources requested by the client exist on the server.


500 (internal server error): A program error occurs on the server.





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.