目录搜索
GuidesAccess control CORSAuthenticationBrowser detection using the user agentCachingCaching FAQCompressionConditional requestsConnection management in HTTP 1.xContent negotiationContent negotiation: List of default Accept valuesCookiesCSPMessagesOverviewProtocol upgrade mechanismProxy servers and tunnelingProxy servers and tunneling: Proxy Auto-Configuration (PAC) filePublic Key PinningRange requestsRedirectionsResources and specificationsResources and URIsResponse codesServer-Side Access ControlSessionGuides: BasicsBasics of HTTPChoosing between www and non-www URLsData URIsEvolution of HTTPIdentifying resources on the WebMIME TypesMIME types: Complete list of MIME typesCSPContent-Security-PolicyContent-Security-Policy-Report-OnlyCSP: base-uriCSP: block-all-mixed-contentCSP: child-srcCSP: connect-srcCSP: default-srcCSP: font-srcCSP: form-actionCSP: frame-ancestorsCSP: frame-srcCSP: img-srcCSP: manifest-srcCSP: media-srcCSP: object-srcCSP: plugin-typesCSP: referrerCSP: report-uriCSP: require-sri-forCSP: sandboxCSP: script-srcCSP: style-srcCSP: upgrade-insecure-requestsCSP: worker-srcHeadersAcceptAccept-CharsetAccept-EncodingAccept-LanguageAccept-RangesAccess-Control-Allow-CredentialsAccess-Control-Allow-HeadersAccess-Control-Allow-MethodsAccess-Control-Allow-OriginAccess-Control-Expose-HeadersAccess-Control-Max-AgeAccess-Control-Request-HeadersAccess-Control-Request-MethodAgeAllowAuthorizationCache-ControlConnectionContent-DispositionContent-EncodingContent-LanguageContent-LengthContent-LocationContent-RangeContent-TypeCookieCookie2DateDNTETagExpectExpiresForwardedFromHeadersHostIf-MatchIf-Modified-SinceIf-None-MatchIf-RangeIf-Unmodified-SinceKeep-AliveLarge-AllocationLast-ModifiedLocationOriginPragmaProxy-AuthenticateProxy-AuthorizationPublic-Key-PinsPublic-Key-Pins-Report-OnlyRangeRefererReferrer-PolicyRetry-AfterServerSet-CookieSet-Cookie2SourceMapStrict-Transport-SecurityTETkTrailerTransfer-EncodingUpgrade-Insecure-RequestsUser-AgentUser-Agent: FirefoxVaryViaWarningWWW-AuthenticateX-Content-Type-OptionsX-DNS-Prefetch-ControlX-Forwarded-ForX-Forwarded-HostX-Forwarded-ProtoX-Frame-OptionsX-XSS-ProtectionMethodsCONNECTDELETEGETHEADMethodsOPTIONSPATCHPOSTPUTStatus100 Continue101 Switching Protocols200 OK201 Created202 Accepted203 Non-Authoritative Information204 No Content205 Reset Content206 Partial Content300 Multiple Choices301 Moved Permanently302 Found303 See Other304 Not Modified307 Temporary Redirect308 Permanent Redirect400 Bad Request401 Unauthorized403 Forbidden404 Not Found405 Method Not Allowed406 Not Acceptable407 Proxy Authentication Required408 Request Timeout409 Conflict410 Gone411 Length Required412 Precondition Failed413 Payload Too Large414 URI Too Long415 Unsupported Media Type416 Range Not Satisfiable417 Expectation Failed426 Upgrade Required428 Precondition Required429 Too Many Requests431 Request Header Fields Too Large451 Unavailable For Legal Reasons500 Internal Server Error501 Not Implemented502 Bad Gateway503 Service Unavailable504 Gateway Timeout505 HTTP Version Not Supported511 Network Authentication RequiredStatus
文字

Accept-Language请求的 HTTP 标头通告哪些语言客户端是能够理解,并且其区域的变体是优选的。使用内容协商,服务器然后选择其中一个提议,使用它并通过Content-Language响应头通知客户它的选择。浏览器根据它们的用户界面语言为该标题设置足够的值,并且即使用户可以改变它,这也很少发生(并且因为它导致指纹)而被忽视。

当服务器无法通过另一种方式确定语言时,使用此标题是一种暗示,例如特定的 URL ,由明确的用户决定控制。建议服务器不要重写明确的决定。该内容Accept-Language通常不受用户的控制(例如在不同国家旅行和使用网吧时); 用户可能还想用除用户界面的语言环境之外的其他语言访问页面。

如果服务器无法提供任何匹配的语言,理论上可以发回406(不可接受的)错误代码。但是,为了获得更好的用户体验,很少做到这一点,更常见的方式是Accept-Language在这种情况下忽略 header 。

Header type

Request header

Forbidden header name

no

CORS-safelisted request-header

yes

语法

Accept-Language: <language>Accept-Language: <locale>Accept-Language: *// Multiple types, weighted with the quality value syntax:Accept-Language: fr-CH, fr;q=0.9, en;q=0.8, de;q=0.7, *;q=0.5

指令

<language>以2或3个字符的字符串表示的语言。

<locale>完整的语言标签。除了语言本身之外,它可能包含更多的信息'-'。最常见的额外信息是国家变体(如'en-US')或使用的字母类型(如'sr-Lat')。其他类似正字法('de-DE-1996')的变体通常不用于此标题的上下文中。

*任何语言; '*'被用作通配符。

;q=(q因子权重)使用称为权重的相对质量值以优先顺序表示的任何值。

例子

Accept-Language: de

Accept-Language: de-CH

Accept-Language: en-US,en;q=0.5

规范

Specification

Title

RFC 7231, section 5.3.5: Accept-Language

Hypertext Transfer Protocol (HTTP/1.1): Semantics and Context

浏览器兼容性

Feature

Chrome

Firefox

Edge

Internet Explorer

Opera

Safari

Basic Support

(Yes)

(Yes)

(Yes)

(Yes)

(Yes)

(Yes)

Feature

Android

Chrome for Android

Edge mobile

Firefox for Android

IE mobile

Opera Android

iOS Safari

Basic Support

(Yes)

(Yes)

(Yes)

(Yes)

(Yes)

(Yes)

(Yes)

上一篇:下一篇: