"Graphical http" chapter 2-6: Basics, messages, status codes, headers.

Source: Internet
Author: User
Tags http authentication ranges web hosting web hosting services

HTTP protocols and Cookies

Is the stateless protocol, which itself does not save the communication state between the request and the response. But with the development of technology, in order to realize the function of saving State, we introduce the cookie technology.

Cookies write information in request and response messages to control the state of the client.

    1. The cookie notifies the client to save the cookie based on the header field information from the Set-cookie in the response message sent from the server.
    2. The next time the client sends a request, a cookie value is added to the message.
    3. After the server receives the message, it checks the cookie, confirms which client sent the connection request, and then compares the records on the server to get the previous status information.

HTTP method that informs the server of intent:

Get,post

HEAD: Gets the header of the message and does not return the main part. Used to confirm the validity of the URL and the date time for resource updates.

PUT, DELETE: Does not have a validation mechanism, only used in conjunction with web App validation mechanisms or when complying with rest standards.

Options: Ask a supported method

Connect: Requires a tunneling protocol to connect to the proxy.

Persistent connection, HTTP1.1 features:

It does not disconnect after every HTTP communication, which reduces the burden of repeatedly establishing connections and disconnects.

pipelining : When connecting, sending requests and responding to requests are separated. Multiple requests can be sent in parallel without waiting for a response one after another.

3rd. Information in HTTP messages

Previous blog (with image) https://www.cnblogs.com/chentianwei/p/9485301.html

3.1 Message Message

Divided into: general-Purpose header, request header, response header, entity header 4. Common to see the table before the blog.

3.4 Multi-part object collection for sending multiple dataMultipart

The message body sent by the HTTP protocol can contain multiple types of entities, usually used when uploading pictures or text files:

Multipart/form-data: Form Upload

Multipart/byteranges: Status Code 206 Response message contains multiple ranges of content when used

Use Content-type, and add boundary=xxx

Each object in the collection object is distinguished by using--xxx, and the final end is represented by the--xxx--flag.

3.5 Getting part of the content (picture) request

The large picture download process, once interrupted, does not require a new download because it uses the range Request. Similar to the big picture cut into a few parts, like a bag.

Content-range:bytes 5001-10000/10000

4th Chapter Status Code

More than 60 kinds, commonly used 14 kinds.

200:ok

204:no Content, the request was processed successfully, but the returned response message does not have a body part.

206:partial Content, which indicates that the client has a range request, the server successfully executed this part of the GET request. The response message contains the entity content specified by the Content-range.

301:move permanently, which indicates that the requested resource has been assigned a new URL, should use the URL that the resource now points to.

302:found, which represents a temporary redirect, indicates that the requested resource is assigned a new URL and is expected to be accessed using this URL.

303:see other, which indicates that another URL exists for the requested resource, should be directed to get the requested resource using the Get method . The others are similar to 302.

304:not Modified, which indicates that the client sends a conditional request , the server allows the request to access the resource but does not meet the condition. 304 returns, without the body part of the response.

?? (If-match, If-modified-since,if-none-match, If-range, if-unmodified-since) header

307:temporary redirect equals 302, the industry is accustomed to post into get.

400:bad request, which indicates a syntax error in the requested message?

401 Unauthorized, which means HTTP authentication is required

403 Forbidden, the server denies access to the requested resource. The body part of the entity looks at the description of the cause.

404 Not Found, the requested resource cannot be found on the server, and can be used when the server side rejects the request and does not want to justify it.

Internal Server error, which indicates that the server appears when executing the request?, bug, temporary failure.

503 Service unavailable, which indicates that the server is temporarily unavailable, overloaded, and downtime maintained.

?? The status code may not be the same as the real situation.

The 5th chapter, and the HTTP collaboration Web server. 5.1 Virtual Host Technology

Let a server host n multiple domain names. This is what the provider of web hosting services does.

Therefore, to send an HTTP request, you must use the full host name or the domain name URL

5.2 Communication Data Forwarding program

Proxy: use a proxy server to reduce network bandwidth traffic (leveraging caching technology)

Caching AgentProxy: Stores the response message sent from the source server on the proxy server.

Cache validity period. The client can also be cached.

Gateways: similar to proxies, but can provide non-HTTP protocol services. Increased security, such as connecting to a database, connecting a credit card billing system

tunneling: use encryption such as SSL to communicate. Ensure secure communication.

6th Chapter HTTP Header

4 different types:

General Header Fields,

Request Header fields, which complements the requested additional content, client information, and response content-related priority information.

Response Header fields, which complements the additional content of the response, will also require the client to attach additional content information.

Entity header fields, the header used in the Message Entity section, complements the object-related message such as resource content update time.

See book 85 page for detailed explanation

Request header Fields

6.3 HTTP1.1 General header field 6.31cache-control (There were 20 orders ., see page 86)

public/private: Whether other users can also take advantage of the cache.

No-cache: The actual meaning is not to cache expired resources

If it is a response instruction, it must be validated before the cache is represented. If it is a request instruction, the delegate does not cache the resource to the source server.

Purpose: Prevents expired resources from being returned from the cache.

No-store: Do not store cache resources, really do not cache.

6.32 Connection
    • Control the header field that is no longer forwarded to the agent Connection: Header field name no longer forwarded
    • Manage persistent connections. connection:close/keep-alive

6.33 date when the message was created. 6.36 transfer-encoding:chunked

Specifies the encoding method for using split-speed transmission.

6.38 Via

Used to track the transmission path, the message passes through the proxy and the gateway and appends the server information to the Via.

6.39 Warning (see page 98 for details)

A warning that informs the user of some issues related to caching.

Warning: [Warning Code] [host: Port number] "[Warning content]" ([datetime])

6.4 Request Header fields

6.41 Accept

6.45 Authorization

6.47 Host

6.48 If-match

If the asterisk is *,if-match:*, the ETag value is ignored. Deal with resources as long as they exist.

If-match and If-none-match act in the opposite direction.

6.5 Response header Fields

6.51 accept-ranges

6.53ETag

6.6 Entity Header fields6.66 content-md5

6.7 Header fields for the cookie service (130 pages)

Working mechanism: User identification, state management.

Set-cookie: Response Header Field

Cookie: Request Header Field

Property:

"Graphical http" chapter 2-6: Basics, messages, status codes, headers.

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.