简体   繁体   English

HTTP1.1协议多国语言

[英]HTTP1.1 Protocol MultiLanguage

I'm working in a crawler and I want to know if the page accept multiple languages. 我在搜寻器中工作,我想知道页面是否接受多种语言。 My request is as follows: 我的要求如下:

GET www.stackoverflow.com HTTP/1.1
Host: www.stackoverflow.com
Accept-Language: en

How I know in the response if they accept more than one language? 我如何知道他们是否接受多种语言? In the header? 在标题中? Content language specifies just one? 内容语言仅指定一种?

(this is an example header, not the stackoverflow answer) (这是示例标头,而不是stackoverflow答案)

HTTP/1.1·200·OK
Date:·Sat,·06·Set·2014·15:52:50·GMT
Server:·Apache/2
Content-Location:·qa-http-and-lang.en.php
Vary:·negotiate,accept-language,Accept-Encoding
TCN:·choice
P3P:·policyref="http://www.w3.org/2001/05/P3P/p3p.xml"
Connection:·close
Transfer-Encoding:·chunked
Content-Type:·text/html; charset=utf-8
Content-Language:·en

In first place you don´t have to set the Accept-Language attribute. 首先,您不必设置Accept-Language属性。 You only have to parse the HTTP response and get Content-Language. 您只需要解析HTTP响应并获取Content-Language。 It should have the values for all the languages that the content is intended. 它应该具有内容所要使用的所有语言的值。 If no Content-Language is specified, the default is that the content is intended for all language audiences. 如果未指定Content-Language,则默认值为该内容适用于所有语言的受众。 This might mean that the sender does not consider it to be specific to any natural language, or that the sender does not know for which language it is intended. 这可能意味着发件人不认为它是特定于任何自然语言的,或者发件人不知道它打算使用哪种语言。

So, if Content-Language is specified and have more than 1 value then the page accept multiple languages and if no Content-Language is specified you should decide if you consider that it accepts multiple languages or not. 因此,如果指定了Content-Language且其值大于1,则页面接受多种语言;如果未指定Content-Language,则应决定是否考虑它接受多种语言。

Reference: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.12 参考: http : //www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.12

Hope it helps 希望能帮助到你

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM