HTTP - MDN Web Docs
Có thể bạn quan tâm
- Skip to main content
- Skip to search
HTTP is an application-layer protocol for transmitting hypermedia documents, such as HTML. It was designed for communication between web browsers and web servers, but it can also be used for other purposes, such as machine-to-machine communication, programmatic access to APIs, and more.
HTTP follows a classical client-server model, with a client opening a connection to make a request, then waiting until it receives a response from the server. HTTP is a stateless protocol, meaning that the server does not keep any session data between two requests, although the later addition of cookies adds state to some client-server interactions.
In this article
- Guides
- Tools & resources
- Reference
Guides
HTTP is an extensible protocol that relies on concepts like resources and Uniform Resource Identifiers (URIs), a basic message structure, and client-server communication model. On top of these concepts, numerous extensions have been developed over the years that add functionality and updated semantics, including additional HTTP methods and headers.
The HTTP guides are listed in order from general overviews to specialized, use-case-driven topics. Beginners are encouraged to start with the foundational guides before exploring more focused articles.
Overview of HTTPThe basic features of HTTP, what it can do, its intended use in web architecture, and its position in the protocol stack.
Evolution of HTTPHTTP was created in the early 1990s and has been extended several times. This article goes through its history and describes HTTP/0.9, HTTP/1.0, HTTP/1.1, through HTTP/2 and HTTP/3, as well as novelties introduced over the years.
A typical HTTP sessionDescribes the flow of an HTTP session, from establishing a connection, sending a request, to receiving a response.
HTTP messagesHTTP messages transmitted as requests and responses have a defined structure. This article describes this general structure, its purpose, and the different types of messages.
MIME typesSince HTTP/1.0, different types of content can be transmitted. This article explains how this is accomplished using the Content-Type header and the MIME standard. A shortlist of common types used by web developers can be found in Common MIME types.
Compression in HTTPBrowsers and servers compress their messages before sending them over the network to reduce the amount of data that needs to be transmitted, improving transfer speed and bandwidth utilization.
HTTP cachingCaching is a highly important mechanism for delivering fast experiences on the Web and for efficient use of resources. This article describes different methods of caching and how to use HTTP headers to control them.
HTTP authenticationAuthentication is a way to verify the identity of a client when making requests to a server. It ensures that only authorized users or systems can access certain resources.
Using HTTP cookiesAlthough HTTP is a stateless protocol, a server can send a Set-Cookie header with the response. The client then returns the cookie's value with every subsequent request to the server in the form of a Cookie request header. This adds the ability to store and exchange a small amount of data which effectively adds state to some client-server interactions.
Redirections in HTTPURL redirection, also known as URL forwarding, is a technique to give more than one URL address to a page, a form, a whole website, or a web application. HTTP has a special kind of response, called a HTTP redirect, for this operation.
HTTP conditional requestsIn conditional requests, the outcome of a request depends on the value of a validator in the request. This method is used heavily in caching and use cases such as resuming a download, preventing lost updates when modifying a document on the server, and more.
HTTP range requestsA range request asks the server to send a specific part (or parts) of a resource back to a client instead of the full resource. Range requests are useful for cases when a client knows they need only part of a large file, or for cases where an application allows the user to pause and resume a download.
Content negotiationHTTP defines a set of message headers, starting with Accept as a way for a browser to announce the format, language, or encoding it prefers. This article explains how this advertisement happens, how the server is expected to react, and how it chooses the most adequate response to a request.
Connection management in HTTP/1.xHTTP/1.1 was the first version of HTTP to support persistent connections and pipelining. This article explains both concepts, including the pros and cons of each.
Protocol upgrade mechanismHTTP/1.1 provides a mechanism to upgrade an already-established connection to a different protocol using the Upgrade header. A client can upgrade a connection from HTTP/1.1 to HTTP/2, or an HTTP(S) connection to a WebSocket (ws / wss).
Proxy servers and tunnelingA proxy can be on the user's local computer, or anywhere between the user's computer and a destination server on the Internet. This page outlines some basics about proxies and introduces a few configuration options.
HTTP Client hintsClient Hints are a set of response headers that a server can use to proactively request information from a client about the device, network, user, and user-agent-specific preferences. The server can then determine which resources to send, based on the information that the client chooses to provide.
Network Error Logging ExperimentalNetwork Error Logging is a mechanism that can be configured via the NEL HTTP response header. This experimental header allows websites and applications to opt-in to receive reports about failed (or even successful) network fetches from supporting browsers.
Browser detection using the user agentIt's very rarely a good idea to use user agent sniffing to detect a browser, but there are edge cases that require it. This document will guide you in doing this as correctly as possible when this is necessary, with an emphasis on considerations to make before embarking on this route.
Security and privacy
Permissions PolicyPermissions Policy provides mechanisms for web developers to explicitly declare what functionality can and cannot be used on a website. You define a set of "policies" that restrict what APIs the site's code can access or modify the browser's default behavior for certain features.
Cross-Origin Resource Sharing (CORS)Cross-site HTTP requests are requests for resources from a different domain than that of the resource making the request. Web pages today very commonly load cross-site resources, for example, a page 'Domain A' (http://domaina.example/) requests an image on 'Domain B' (http://domainb.foo/image.jpg) via the img element. CORS allows web developers to control how their site reacts to cross-site requests.
Content Security Policy (CSP)CSP allows website administrators to use the Content-Security-Policy response header to control which resources the client is allowed to load for a given page. The CSP guide describes the overall Content Security Policy mechanism which helps detect and mitigate certain types of attacks, including Cross-Site Scripting (XSS) and data injection attacks.
Cross-Origin Resource Policy (CORP)CORP lets websites and applications opt in to protection against specific requests from other origins (such as those issued with elements like <script> and <img>), to mitigate speculative side-channel attacks.
Mozilla web security guidelinesA collection of tips to help operational teams with creating secure web applications.
Related resources
URIsUniform Resource Identifiers (URIs) are used to describe and locate resources on the web and are an essential component in HTTP requests.
Configuring servers for Ogg mediaThis guide covers a few server configuration changes that may be necessary for your web server to correctly serve Ogg media files. This information may also be useful if you encounter other media types your server isn't already configured to recognize.
Tools & resources
Helpful tools and resources for understanding and debugging HTTP.
Firefox Developer ToolsNetwork monitor
HTTP ObservatoryA project designed to help developers, system administrators, and security professionals configure their sites safely and securely.
RedBotTools to check your cache-related headers.
nghttp2An HTTP/2 client, server and proxy implementation written in C with load test and benchmarking tools and an HPACK encoder and decoder.
curlA command-line tool for transferring data specified with URL syntax. Supports HTTP, HTTPS, WS, WSS, among many other protocols.
How Browsers Work (2011)A very comprehensive article on browser internals and request flow through HTTP protocol.
Reference
The HTTP reference documentation contains detailed information about headers, request methods, status responses, and lists relevant specifications and standards documents.
HTTP headersMessage headers are used to send metadata about a resource or a HTTP message, and to describe the behavior of the client or the server.
HTTP request methodsRequest methods indicate the purpose of the request and what is expected if the request is successful. The most common methods are GET and POST for retrieving and sending data to servers, respectively, but there are other methods which serve different purposes.
HTTP response status codesResponse status codes indicate the outcome of a specific HTTP request. Responses are grouped in five classes: informational, successful, redirections, client errors, and server errors.
HTTP resources and specificationsThis page lists relevant resources about HTTP since it was first specified in the early 1990s.
The following subsections are also notable:
CSP directivesThe Content-Security-Policy (CSP) response header allows website administrators to specify which resources the user agent is allowed to load for a given page. This section lists directives that can be used in a CSP header, with individual documentation pages that describe how the directives work and how to use them.
Permissions-Policy directivesThe Permissions-Policy response header provides a mechanism to allow or deny the use of browser features in a document or within any <iframe> element in the document. This section lists directives that can be used in a Permissions-Policy header, with individual documentation pages that describe how the directives work and how to use them.
Help improve MDN
Was this page helpful to you? Yes No Learn how to contributeThis page was last modified on Dec 22, 2025 by MDN contributors.
View this page on GitHub • Report a problem with this content Filter sidebar- HTTP
- Guides
- Overview of HTTP
- Evolution of HTTP
- A typical HTTP session
- HTTP messages
- Media types
- Common types
- Compression in HTTP
- HTTP caching
- HTTP authentication
- Using HTTP cookies
- Redirections in HTTP
- Conditional requests
- Range requests
- Client hints
- User-Agent reduction
- Compression Dictionary Transport Experimental
- Network Error Logging Experimental
- Content negotiation
- Default Accept values
- Browser detection using the UA string
- Connection management in HTTP/1.x
- Protocol upgrade mechanism
- Proxy servers and tunneling
- Proxy Auto-Configuration (PAC) file
- Security and privacy
- HTTP Observatory
- Practical implementation guides
- Permissions Policy Experimental
- Cross-Origin Resource Policy (CORP)
- IFrame credentialless Experimental
- Cross-Origin Resource Sharing (CORS)
- CORS errors
- Reason: CORS disabled
- Reason: CORS header 'Access-Control-Allow-Origin' does not match 'xyz'
- Reason: CORS header 'Access-Control-Allow-Origin' missing
- Reason: CORS header 'Origin' cannot be added
- Reason: CORS preflight channel did not succeed
- Reason: CORS request did not succeed
- Reason: CORS request external redirect not allowed
- Reason: CORS request not HTTP
- Reason: Credential is not supported if the CORS header 'Access-Control-Allow-Origin' is '*'
- Reason: Did not find method in CORS header 'Access-Control-Allow-Methods'
- Reason: expected 'true' in CORS header 'Access-Control-Allow-Credentials'
- Reason: invalid token 'xyz' in CORS header 'Access-Control-Allow-Headers'
- Reason: invalid token 'xyz' in CORS header 'Access-Control-Allow-Methods'
- Reason: missing token 'xyz' in CORS header 'Access-Control-Allow-Headers' from CORS preflight channel
- Reason: Multiple CORS header 'Access-Control-Allow-Origin' not allowed
- Content Security Policy (CSP)
- Errors and warnings
- Reference
- HTTP headers
- Accept
- Accept-CH
- Accept-Encoding
- Accept-Language
- Accept-Patch
- Accept-Post
- Accept-Ranges
- Access-Control-Allow-Credentials
- Access-Control-Allow-Headers
- Access-Control-Allow-Methods
- Access-Control-Allow-Origin
- Access-Control-Expose-Headers
- Access-Control-Max-Age
- Access-Control-Request-Headers
- Access-Control-Request-Method
- Activate-Storage-Access
- Age
- Allow
- Alt-Svc
- Alt-Used
- Attribution-Reporting-Eligible Deprecated
- Attribution-Reporting-Register-Source Deprecated
- Attribution-Reporting-Register-Trigger Deprecated
- Authorization
- Available-Dictionary Experimental
- Cache-Control
- Clear-Site-Data
- Connection
- Content-Digest
- Content-Disposition
- Content-DPR Non-standard Deprecated
- Content-Encoding
- Content-Language
- Content-Length
- Content-Location
- Content-Range
- Content-Security-Policy
- Content-Security-Policy-Report-Only
- Content-Type
- Cookie
- Critical-CH Experimental
- Cross-Origin-Embedder-Policy
- Cross-Origin-Opener-Policy
- Cross-Origin-Resource-Policy
- Date
- Device-Memory Non-standard Deprecated
- Dictionary-ID Experimental
- DNT Non-standard Deprecated
- Downlink Experimental
- DPR Non-standard Deprecated
- Early-Data Experimental
- ECT Experimental
- ETag
- Expect
- Expect-CT Deprecated
- Expires
- Forwarded
- From
- Host
- Idempotency-Key Experimental
- If-Match
- If-Modified-Since
- If-None-Match
- If-Range
- If-Unmodified-Since
- Integrity-Policy
- Integrity-Policy-Report-Only
- Keep-Alive
- Last-Modified
- Link
- Location
- Max-Forwards
- NEL Experimental
- No-Vary-Search Experimental
- Observe-Browsing-Topics Non-standard Deprecated
- Origin
- Origin-Agent-Cluster
- Permissions-Policy Experimental
- Pragma Deprecated
- Prefer
- Preference-Applied
- Priority
- Proxy-Authenticate
- Proxy-Authorization
- Range
- Referer
- Referrer-Policy
- Refresh
- Report-To Non-standard Deprecated
- Reporting-Endpoints
- Repr-Digest
- Retry-After
- RTT Experimental
- Save-Data Experimental
- Sec-Browsing-Topics Non-standard Deprecated
- Sec-CH-Device-Memory Experimental
- Sec-CH-DPR Experimental
- Sec-CH-Prefers-Color-Scheme Experimental
- Sec-CH-Prefers-Reduced-Motion Experimental
- Sec-CH-Prefers-Reduced-Transparency Experimental
- Sec-CH-UA Experimental
- Sec-CH-UA-Arch Experimental
- Sec-CH-UA-Bitness Experimental
- Sec-CH-UA-Form-Factors Experimental
- Sec-CH-UA-Full-Version Deprecated
- Sec-CH-UA-Full-Version-List Experimental
- Sec-CH-UA-Mobile Experimental
- Sec-CH-UA-Model Experimental
- Sec-CH-UA-Platform Experimental
- Sec-CH-UA-Platform-Version Experimental
- Sec-CH-UA-WoW64 Experimental
- Sec-CH-Viewport-Height Experimental
- Sec-CH-Viewport-Width Experimental
- Sec-CH-Width
- Sec-Fetch-Dest
- Sec-Fetch-Mode
- Sec-Fetch-Site
- Sec-Fetch-Storage-Access
- Sec-Fetch-User
- Sec-GPC Experimental
- Sec-Private-State-Token Experimental
- Sec-Private-State-Token-Crypto-Version Experimental
- Sec-Private-State-Token-Lifetime Experimental
- Sec-Purpose
- Sec-Redemption-Record Experimental
- Sec-Speculation-Tags Experimental
- Sec-WebSocket-Accept
- Sec-WebSocket-Extensions
- Sec-WebSocket-Key
- Sec-WebSocket-Protocol
- Sec-WebSocket-Version
- Server
- Server-Timing
- Service-Worker
- Service-Worker-Allowed
- Service-Worker-Navigation-Preload
- Set-Cookie
- Set-Login
- SourceMap
- Speculation-Rules Experimental
- Strict-Transport-Security
- Supports-Loading-Mode Experimental
- TE
- Timing-Allow-Origin
- Tk Non-standard Deprecated
- Trailer
- Transfer-Encoding
- Upgrade
- Upgrade-Insecure-Requests
- Use-As-Dictionary Experimental
- User-Agent
- Vary
- Via
- Viewport-Width Non-standard Deprecated
- Want-Content-Digest
- Want-Repr-Digest
- Warning Deprecated
- Width Non-standard Deprecated
- WWW-Authenticate
- X-Content-Type-Options
- X-DNS-Prefetch-Control Non-standard
- X-Forwarded-For Non-standard
- X-Forwarded-Host Non-standard
- X-Forwarded-Proto Non-standard
- X-Frame-Options
- X-Permitted-Cross-Domain-Policies Non-standard
- X-Powered-By Non-standard
- X-Robots-Tag Non-standard
- X-XSS-Protection Non-standard Deprecated
- HTTP request methods
- CONNECT
- DELETE
- GET
- HEAD
- OPTIONS
- PATCH
- POST
- PUT
- TRACE
- HTTP response status codes
- 100 Continue
- 101 Switching Protocols
- 102 Processing
- 103 Early Hints
- 200 OK
- 201 Created
- 202 Accepted
- 203 Non-Authoritative Information
- 204 No Content
- 205 Reset Content
- 206 Partial Content
- 207 Multi-Status
- 208 Already Reported
- 226 IM Used
- 300 Multiple Choices
- 301 Moved Permanently
- 302 Found
- 303 See Other
- 304 Not Modified
- 307 Temporary Redirect
- 308 Permanent Redirect
- 400 Bad Request
- 401 Unauthorized
- 402 Payment Required
- 403 Forbidden
- 404 Not Found
- 405 Method Not Allowed
- 406 Not Acceptable
- 407 Proxy Authentication Required
- 408 Request Timeout
- 409 Conflict
- 410 Gone
- 411 Length Required
- 412 Precondition Failed
- 413 Content Too Large
- 414 URI Too Long
- 415 Unsupported Media Type
- 416 Range Not Satisfiable
- 417 Expectation Failed
- 418 I'm a teapot
- 421 Misdirected Request
- 422 Unprocessable Content
- 423 Locked
- 424 Failed Dependency
- 425 Too Early
- 426 Upgrade Required
- 428 Precondition Required
- 429 Too Many Requests
- 431 Request Header Fields Too Large
- 451 Unavailable For Legal Reasons
- 500 Internal Server Error
- 501 Not Implemented
- 502 Bad Gateway
- 503 Service Unavailable
- 504 Gateway Timeout
- 505 HTTP Version Not Supported
- 506 Variant Also Negotiates
- 507 Insufficient Storage
- 508 Loop Detected
- 510 Not Extended
- 511 Network Authentication Required
- CSP directives
- base-uri
- block-all-mixed-content Deprecated
- child-src
- connect-src
- default-src
- fenced-frame-src Experimental
- font-src
- form-action
- frame-ancestors
- frame-src
- img-src
- manifest-src
- media-src
- object-src
- prefetch-src Non-standard Deprecated
- report-to
- report-uri Deprecated
- require-trusted-types-for
- sandbox
- script-src
- script-src-attr
- script-src-elem
- style-src
- style-src-attr
- style-src-elem
- trusted-types
- upgrade-insecure-requests
- worker-src
- Permissions-Policy directives Experimental
- accelerometer Experimental
- ambient-light-sensor Experimental
- aria-notify Experimental Non-standard
- attribution-reporting Deprecated
- autoplay Experimental
- bluetooth Experimental
- browsing-topics Non-standard Deprecated
- camera Experimental
- captured-surface-control Experimental
- compute-pressure Experimental
- cross-origin-isolated Experimental
- deferred-fetch Experimental
- deferred-fetch-minimal Experimental
- display-capture Experimental
- encrypted-media Experimental
- fullscreen Experimental
- gamepad Experimental
- geolocation Experimental
- gyroscope Experimental
- hid Experimental
- identity-credentials-get Experimental
- idle-detection Experimental
- language-detector Experimental
- local-fonts Experimental
- magnetometer Experimental
- microphone Experimental
- midi Experimental
- on-device-speech-recognition Experimental
- otp-credentials Experimental
- payment Experimental
- picture-in-picture Experimental
- private-state-token-issuance Experimental
- private-state-token-redemption Experimental
- publickey-credentials-create Experimental
- publickey-credentials-get Experimental
- screen-wake-lock Experimental
- serial Experimental
- speaker-selection Experimental
- storage-access Experimental
- summarizer Experimental
- translator Experimental
- usb Experimental
- web-share Experimental
- window-management Experimental
- xr-spatial-tracking Experimental
- HTTP resources and specifications
Từ khóa » Http://2nds.biz
-
Welcome To Southeastern Salvage Home Emporium
-
Sgcarmart: Singapore No.1 Car Site For New Car & Used Cars
-
Singapore Police Force
-
Twilio: Communication APIs For SMS, Voice, Video & Authentication
-
CNA: Breaking News, Singapore News, World And Asia
-
Find Email Addresses In Seconds • Hunter (Email Hunter)
-
GeoGebra - The World's Favorite, Free Math Tools Used By Over 100 ...
-
Business Intelligence And Analytics Software
-
WhatsApp
-
What Is WhatsApp Business?
-
Businessweek
-
Official Site | Second Life - Virtual Worlds, Virtual Reality, VR ...