search
HomeWeb Front-endH5 TutorialHTTP methods, status codes and components

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
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
HTTP 525状态码介绍:探究其定义和应用HTTP 525状态码介绍:探究其定义和应用Feb 18, 2024 pm 10:12 PM

HTTP525状态码简介:了解其定义和使用方法HTTP(HypertextTransferProtocol)525状态码是指服务器在SSL握手过程中发生错误,导致无法建立安全连接。在传输层安全性(TLS)握手期间发生错误时,服务器将返回此状态码。该状态码属于服务器错误类别,通常表示服务器配置或设置问题。当客户端尝试通过HTTPS连接到服务器时,服务器无

理解网页重定向的常见应用场景并了解HTTP301状态码理解网页重定向的常见应用场景并了解HTTP301状态码Feb 18, 2024 pm 08:41 PM

掌握HTTP301状态码的含义:网页重定向的常见应用场景随着互联网的迅猛发展,人们对网页交互的要求也越来越高。在网页设计领域,网页重定向是一种常见且重要的技术,通过HTTP301状态码来实现。本文将探讨HTTP301状态码的含义以及在网页重定向中的常见应用场景。HTTP301状态码是指永久重定向(PermanentRedirect)。当服务器接收到客户端发

HTTP 200 OK:了解成功响应的含义与用途HTTP 200 OK:了解成功响应的含义与用途Dec 26, 2023 am 10:25 AM

HTTP状态码200:探索成功响应的含义与用途HTTP状态码是用来表示服务器响应状态的数字代码。其中,状态码200表示请求已成功被服务器处理。本文将探索HTTP状态码200的具体含义与用途。首先,让我们了解一下HTTP状态码的分类。状态码被分为五个类别,分别是1xx、2xx、3xx、4xx和5xx。其中,2xx表示成功的响应。而200是2xx中最常见的状态码

对于HTTP请求超时会返回哪种状态码?对于HTTP请求超时会返回哪种状态码?Feb 18, 2024 pm 01:58 PM

HTTP请求超时,服务器端常常会返回504GatewayTimeout状态码。该状态码表示服务器在执行某个请求时,经过一段时间后仍未能获取到请求所需的资源或完成请求的处理。它是5xx系列的状态码,表示服务器端遇到了临时的问题或过载,导致无法正确处理客户端的请求。在HTTP协议中,各种状态码都有特定的含义和用途,而504状态码则用于表示请求超时问题。在客户

解读HTTP状态码301:如何正确处理永久重定向错误解读HTTP状态码301:如何正确处理永久重定向错误Feb 20, 2024 pm 03:21 PM

解读HTTP状态码301:如何正确处理永久重定向错误HTTP状态码是Web应用中非常重要的一部分,它们向客户端提供了关于请求的处理状态的信息。301状态码是一个特殊的状态码,它表示所请求的资源已被永久性转移到新的位置。在本文中,我们将解读301状态码,并探讨如何正确处理永久重定向错误。一、理解301状态码当服务器接收到客户端发出的请求时,如果所请求的资源已被

如何获得http状态码如何获得http状态码Oct 12, 2023 pm 04:11 PM

获得http状态码的方法使用浏览器和使用编程语言等。详细介绍:1、使用浏览器,当在浏览器中访问一个网页时,浏览器会向服务器发送HTTP请求,并在接收到服务器的响应后显示网页内容,浏览器通常会在页面的开发者工具中显示HTTP状态码;2、使用编程语言,如果想通过编程的方式获取HTTP状态码,可以使用各种编程语言提供的库和函数。

分析和修复服务器内部错误:HTTP状态码500分析和修复服务器内部错误:HTTP状态码500Dec 26, 2023 pm 04:40 PM

HTTP状态码500:分析服务器内部错误及其修复方案摘要:HTTP状态码500表示服务器内部错误,是客户端向服务器发送请求时,服务器遇到了无法处理的错误而无法完成请求。本文将分析导致服务器内部错误的可能原因,并提出相应的修复方案。一、引言HTTP(HypertextTransferProtocol)是一种用于传输超文本的应用层协议,它是客户端和服务器之间

404错误的原因和解决方法的深入研究404错误的原因和解决方法的深入研究Feb 25, 2024 pm 12:21 PM

探究HTTP状态码404的原因和解决途径引言:在浏览网页的过程中,我们经常会遇到HTTP状态码404。这个状态码表示服务器未能找到请求的资源。在本文中,我们将探究HTTP状态码404的原因,并分享一些解决途径。一、HTTP状态码404的原因:1.1资源不存在:最常见的原因就是请求的资源在服务器上不存在。这可能是由于文件被误删、命名错误、路径错误等原因导致。

See all articles

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)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools