Home Web Front-end H5 Tutorial HTTP methods, status codes and components

HTTP methods, status codes and components

May 28, 2017 am 10:53 AM
status code

HttpHypertext Transfer Protocol

HTTP protocol (HyperText Transfer Protocol, Hypertext Transfer Protocol) is used to transfer files from the WWW A transfer protocol used by servers to transmit hypertext to local browsers. It can make the browser more efficient and reduce network transmission. It not only ensures that the computer transmits hypertext documents correctly and quickly, but also determines which part of the document is transmitted and which part of the content is displayed first (such as text before graphics), etc.

The information used for http protocol interaction is called a http message. The http message from the requesting end (client) is called a request message, and the

http

message from the responding end (server) is called a response message. The request message consists of request method

, request

URI, protocol version, header field (optional), content entity (optional) The response message consists of protocol version, status code

, reason phrase, header field (optional), and entity body

In each message, the request URI, protocol version, status code, reason phrase, header field belongs to the message header, then a blank line, and the rest is the message body.

There are 4 types of header fields: request header field, response header field, general header field, entity header field, general header and entity header are the request message and Both response messages have them, while request headers are only available in request messages, and response headers are only available in response messages.

Message is the basic unit in http communication, consisting of 8 bits Composed of byte stream, transmitted through http communication.

The entity is transmitted as the payload data (supplementary item) of the request and response, and its content consists of the entity header and the entity body

Generally, the message body is equal to the entity body . Only when the encoding operation is performed during transmission and the content of the entity body changes, will it be inconsistent with the message body.

http1.0 and http1.1Supported methods

##PUTTransfer files1.0,1.1##HEAD##DELETE(##CONNECTRequires tunneling protocol to connect to proxyLINKUNLINK

Method

Description

Support httpProtocol version

##GET

Get the resource identified by URI

1.0,1.1

##POST

##Transmission Entity Body

1.0,1.1

(

Without verification mechanism)

Get the message header

1.0,1.1

##Delete

file

without verification Mechanism)##1.0,1.1

OPTIONS

##Ask for support methods

1.1

TRACE

Trace path

##1.1

##1.1

Establish connections with resources

1.0

Disconnect link relationship

##1.0

##http

Status code

##Status code

##RedirectionClient Error(Client error status code)##5XXServer Error(Server error status code)Server processing request error

Category

Reason Phrase

1XX

Informational

(Informational status code)

The received request is being processed

##2XX

Success

(success status code)

The request has been processed normally.

##3XX

(Redirect status code)

Additional operations required to complete the request

4XX

The server cannot process the request

Commonly used status codes in

14

##302 FoundURI303 See Other304 Not Modified (the server-side resource is changed, and the client's unexpired resource can be directly used. Body part) indicates that access to the requested resource was denied by the server. No permission to access indicates the server The requested resource cannot be found, that is, there is no such resource Indicates that an error occurred on the server side when executing the request. It may also be that the means The server is temporarily overloaded or is undergoing downtime for maintenance, and is now unable to process requests

httpCommon header field

##200 OK

Indicates that the request from the client is processed normally on the server side

204 No Content

means that the request received by the server has been processed successfully, but the response message returned does not contain the entity body part

206 Partial Content

Indicates that the client made a range request and the server successfully executed it Partial GETRequest

##301 Moved Permaently

A permanent redirect, indicating that the requested resource has been assigned a new

URI and that the # that the resource now refers to should be used in the future. ##URI

Temporary redirection means that the requested resource has been assigned a new

, and we hope that the user can use the new URI to access ## this time.

indicates that the request corresponds to There is another

URI
for the resource. You should use the

GET method to obtain the requested resource

## indicates that the client sends conditions When requesting, the server allows the request to access the resource, but if the request does not meet the conditions, it will directly return 304 Not Modified

307 Temporary Redirect

Temporary redirection, has the same meaning as 302

#400 Bad Request

indicates that there is a syntax error in the request message. The server cannot recognize the request

401 Unauthorized

## means The request sent needs to pass the authentication information of

http authentication. If a request has been made before, it means that the user authentication failed

##403 Forbidden

404 Not Found

500 Internal Server Error

web

application has a

bug
or some temporary Fault

503 Service Unavailable

##ConnectionManage hop-by-hop headers and persistent connectionsPragmaTrailerTransfer-EncodingUpgradeVia

Common header field name

Description

##Cache -Control

##Control the

behavior of cache

Date

##Date and time when the message was created

##Message command

List of headers at the end of the message

Specify the transfer encoding method of the message body

Upgrade to other protocols and check whether higher version protocols can be used for communication

##Related information about the proxy server, tracking the client and server The transmission path between request and response messages

Warning

Error notifications, usually inform users of some warnings about cache-related issues

http1.1 Warning code (Warning has seven types)

##113Heuristic expiration(24199))

Warning code

Warning content

Description

110

Response is stale( Response has expired)

The proxy returns expired resources

##111

Revalidation failed(Revalidation failed)

The agent failed to verify the validity of the resource (the server cannot be reached, etc.)

112

Disconnection operation( Disconnect operation)

# #Agent and Internet link are deliberately cut off

Heuristic expiration

)

##The response period exceeds

hours (when the effective cache setting time is greater than 24 hours)

##Miscellaneous warning(

Miscellaneous warning
)

Any warning content

##214

Tansformation applied(Transformation used

The agent encodes the content or media type etc.

299

Miscellaneous persistent warning(persistent miscellaneous warning

Any warning content

httpRequest header field

##Accept-Prioritized languages, the natural languages ​​that the user agent can handle and the relative priority of the set of natural languagesAuthorizationWebExpectExpect specific behavior from the serverFromUser’s email addressHostThe server where the requested resource is located (host name and port number)If-MatchCompares with the entity tag (##If -Modefied-SinceIf-Modefied-Since ##If-None-MatchRange when it is not updated. If the

Request header field

Description

##Accept

The media types that the user agent can handle and the relative priority of the media types

Accept-Charset

Preferred Character set, the character set supported by the user agent And relative priority

##Accept-Encoding

takes precedence Content encoding, user agent supported content encoding and priority order

Lang

uage

Authentication information

ETag

), if If they are the same, execute the request, otherwise return 412status code

If

field value is earlier than the resource's update time, you want to process the request, otherwise return 304status code

Compare entity tags (the opposite of

If-Match
)

##If-

Resources Send a range request for entity Byte

If-Range field value is consistent with the ETag value or time of the requested resource, it will be processed as a range request, otherwise it will be returned All resources##If-Unmodified-Since

Compare the update time of resources (contrary to If-Modified-Since

)

##Max-Forwards

Maximum transmission hop-by-hop number (specifies the maximum number of servers that can be passed through in decimal form)

Proxy-Authorization

The proxy server requires the client’s authentication information

Range

Byte range request for entity

Referer

To the original getter of URI in the request (the URI of the requested original resource)

##TE

Inform the server that the client can The transfer encoding method and relative priority of processing responses

User-Agent

httpClient program information

## http

Response header field

##DescriptionAccept-RangesAccept-Ranges Byte range requestAgeResource creation process The time, in seconds ##ETagLocationURI##Proxy-AuthenticateInformation of the server
Response header field

Resource The matching information can inform the client of the entity identification

Redirect the client to the specified

Authentication information from the proxy server to the client

##Retry-After

Requirements for the timing of reinitiating the request

Server

http

Installation

##Vary

Proxy server cached management information

WWW-Authenicate

Server authentication information for the client

httpEntity header field

of the corresponding resource

Entity header field

Description

##Allow

httpMethods supported by resources

Content-Encoding

Encoding method applicable to entities

Content-Language

The natural language of entities

Content-Length

The size of the entity (in bytes)

Content-Location

#Replace the URI

Content-MD5

##Entity body message

Summary

Content-Range

The position of the entity body Scope

Content-Type

Media of the entity body Type

Expires

The date and time when the entity body expires

Last-Modified

The date the resource was last modified time

The above is the detailed content of HTTP methods, status codes and components. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Will R.E.P.O. Have Crossplay?
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Introduction to HTTP 525 status code: explore its definition and application Introduction to HTTP 525 status code: explore its definition and application Feb 18, 2024 pm 10:12 PM

Introduction to HTTP 525 status code: Understand its definition and usage HTTP (HypertextTransferProtocol) 525 status code means that an error occurred on the server during the SSL handshake, resulting in the inability to establish a secure connection. The server returns this status code when an error occurs during the Transport Layer Security (TLS) handshake. This status code falls into the server error category and usually indicates a server configuration or setup problem. When the client tries to connect to the server via HTTPS, the server has no

Understand common application scenarios of web page redirection and understand the HTTP 301 status code Understand common application scenarios of web page redirection and understand the HTTP 301 status code Feb 18, 2024 pm 08:41 PM

Understand the meaning of HTTP 301 status code: common application scenarios of web page redirection. With the rapid development of the Internet, people's requirements for web page interaction are becoming higher and higher. In the field of web design, web page redirection is a common and important technology, implemented through the HTTP 301 status code. This article will explore the meaning of HTTP 301 status code and common application scenarios in web page redirection. HTTP301 status code refers to permanent redirect (PermanentRedirect). When the server receives the client's

HTTP 200 OK: Understand the meaning and purpose of a successful response HTTP 200 OK: Understand the meaning and purpose of a successful response Dec 26, 2023 am 10:25 AM

HTTP Status Code 200: Explore the Meaning and Purpose of Successful Responses HTTP status codes are numeric codes used to indicate the status of a server's response. Among them, status code 200 indicates that the request has been successfully processed by the server. This article will explore the specific meaning and use of HTTP status code 200. First, let us understand the classification of HTTP status codes. Status codes are divided into five categories, namely 1xx, 2xx, 3xx, 4xx and 5xx. Among them, 2xx indicates a successful response. And 200 is the most common status code in 2xx

Interpreting HTTP Status Code 301: How to Correctly Handle Permanent Redirect Errors Interpreting HTTP Status Code 301: How to Correctly Handle Permanent Redirect Errors Feb 20, 2024 pm 03:21 PM

Interpreting HTTP Status Code 301: How to Correctly Handle Permanent Redirect Errors HTTP status codes are a very important part of web applications. They provide information to the client about the processing status of the request. The 301 status code is a special status code that indicates that the requested resource has been permanently moved to a new location. In this article, we will interpret the 301 status code and discuss how to properly handle permanent redirect errors. 1. Understand the 301 status code. When the server receives a request from the client, if the requested resource has been

What status code is returned for an HTTP request timeout? What status code is returned for an HTTP request timeout? Feb 18, 2024 pm 01:58 PM

The HTTP request times out, and the server often returns the 504GatewayTimeout status code. This status code indicates that when the server executes a request, it still fails to obtain the resources required for the request or complete the processing of the request after a period of time. It is a status code of the 5xx series, which indicates that the server has encountered a temporary problem or overload, resulting in the inability to correctly handle the client's request. In the HTTP protocol, various status codes have specific meanings and uses, and the 504 status code is used to indicate request timeout issues. in customer

An in-depth discussion of the importance of HTTP protocol status codes An in-depth discussion of the importance of HTTP protocol status codes Feb 25, 2024 pm 11:06 PM

An in-depth interpretation of HTTP protocol status codes: Why status codes are crucial to website development. With the rapid development of the Internet, website development has become more and more important. In website development, the HTTP protocol plays a vital role. It defines the communication specifications between browsers and servers to transfer data through requests and responses. The HTTP status code is part of this process and is used to indicate the processing of the request. This article will provide an in-depth explanation of the role and significance of HTTP protocol status codes. HTTP status code is a three-digit number

How to get http status code How to get http status code Oct 12, 2023 pm 04:11 PM

Methods to obtain http status codes use browsers and use programming languages, etc. Detailed introduction: 1. Using a browser, when accessing a web page in the browser, the browser will send an HTTP request to the server, and display the content of the web page after receiving the response from the server. The browser usually displays the content in the developer tools of the page. Display the HTTP status code in; 2. Use a programming language. If you want to obtain the HTTP status code through programming, you can use libraries and functions provided by various programming languages.

What should I do if 'Uncaught (in promise) Error: Request failed with status code 403' occurs when using axios in a Vue application? What should I do if 'Uncaught (in promise) Error: Request failed with status code 403' occurs when using axios in a Vue application? Jun 24, 2023 pm 01:06 PM

Sending requests using axios is a very common operation in Vue applications. However, when making ajax requests, sometimes you encounter some problems, such as a 403 error. Below we will discuss the problem of "Uncaught(inpromise)Error: Requestfailedwithstatuscode403" when using axios in a Vue application and its solution. First, let us explain error code 403, it

See all articles