首页 \ 问答 \ HTTP状态码300(多选)的确切响应结构是什么?(What is the exact response structure for HTTP status code 300 (Multiple Choices)?)

HTTP状态码300(多选)的确切响应结构是什么?(What is the exact response structure for HTTP status code 300 (Multiple Choices)?)

当用户点击我的网站http://mysite.com/some-drawing上的图形链接时,我希望我的服务器响应状态码300和两个资源位置: http://mysite.com/some-drawing.png : http://mysite.com/some-drawing.pnghttp://mysite.com/some-drawing.myapp ,并让客户端浏览器根据其功能自动决定使用哪一个:

  • 如果MyApp安装在用户的机器上,那么浏览器应该下载*.myapp版本并使用MyApp来显示它。

  • 但是,如果未安装MyApp,且浏览器无法显示此版本,那么我希望它选择*.png版本。

但是,我很难搞清楚状态码为300的HTTP响应的结构。

rfc2616说:

所请求的资源对应于一组表示中的任何一个,每个表示具有其自己的特定位置,并且正在提供代理驱动的协商信息(第12节),以便用户(或用户代理)可以选择优先表示并将其重定向请求到该位置。

除非是HEAD请求,否则响应应该包含一个实体,该实体包含资源特征和位置列表,用户或用户代理可以从中选择最合适的资源特征和位置。 实体格式由Content-Type头部字段中给出的媒体类型指定。 根据用户代理的格式和功能,可以自动选择最合适的选项。 但是,本规范没有为这种自动选择定义任何标准。

如果服务器有一个首选的表示形式,它应该在位置字段中包含该表示的特定URI; 用户代理可以使用位置字段值进行自动重定向。 除非另有说明,否则此响应可缓存。

措辞“ 包含资源特征和位置清单的实体 ”似乎不明确。 这是什么意思? 有人知道这是怎么完成的吗?


When a user clicks a link to a drawing on my site http://mysite.com/some-drawing, I would like my server to respond with status code 300 and two resource locations: http://mysite.com/some-drawing.png and http://mysite.com/some-drawing.myapp, and have the client browser decide automatically which one to use, based on its capabilities:

  • If MyApp is installed on the user's machine, then the browser should download the *.myapp version and use MyApp to display it.

  • However, if MyApp is not installed, and the browser is incapable to display this version, then I would like it to pick the *.png version.

However, I am having a hard time figuring out the structure of a HTTP response with status code 300.

The rfc2616 says:

The requested resource corresponds to any one of a set of representations, each with its own specific location, and agent- driven negotiation information (section 12) is being provided so that the user (or user agent) can select a preferred representation and redirect its request to that location.

Unless it was a HEAD request, the response SHOULD include an entity containing a list of resource characteristics and location(s) from which the user or user agent can choose the one most appropriate. The entity format is specified by the media type given in the Content- Type header field. Depending upon the format and the capabilities of the user agent, selection of the most appropriate choice MAY be performed automatically. However, this specification does not define any standard for such automatic selection.

If the server has a preferred choice of representation, it SHOULD include the specific URI for that representation in the Location field; user agents MAY use the Location field value for automatic redirection. This response is cacheable unless indicated otherwise.

The wording "entity containing a list of resource characteristics and location(s)" seems ambiguous. What does it mean? Does anybody know how this is done?


原文:https://stackoverflow.com/questions/8905545
更新时间:2024-01-17 14:01

最满意答案

如果您试图将外部div居中尊重到其父(本例中为body ),则应将其横向边距设置为auto:

body div{
    margin: auto;
}

正如你可以在这里看到的


If you try to get the outer div centered respect to its parent (bodyin this case) you should set its lateral margins to auto:

body div{
    margin: auto;
}

as you can see here

相关问答

更多
  • 如果您试图将外部div居中尊重到其父(本例中为body ),则应将其横向边距设置为auto: body div{ margin: auto; } 正如你可以在这里看到的 If you try to get the outer div centered respect to its parent (bodyin this case) you should set its lateral margins to auto: body div{ margin: auto; } as you ca ...
  • 简短回答:由于元素是浮动的,所以文本不居中,浮动元素“收缩”到内容,即使它是块级元素。 你能解释更多这意味着什么吗? 我必须将我所有的位置设置为相对的,以便在使用javascript向组件添加组件时使父div更改大小 Finally figured it out. All i needed to do is to add clear:left; to my loginBttn div after that everything worked fine thanks for trying to help ev ...
  • 你可以用CSS来完成(很简单)。 外部div可以是text-align: center和内部div(包含图标) text-align: left display: inline-block : http://jsfiddle.net/ExplosionPIlls/etY4r/ inline-block元素集中在整个div的上下文中,但是当你足够小的窗口大小时,会导致元素包裹在内部元素本身内部,并且它们与左边对齐。 You can do this with just CSS (and quite simply ...
  • 这可以通过使用inline-block显示来完成, float:left将始终将元素发送到其最左边的可能位置。 .gallery { text-align: left; border-style: solid; border-width:3px; border-top-left-radius: 40px; border-bottom-right-radius: 40px; background:yellow; width:335px; padding: ...
  • 好的,我试过这种方式,它对我有用: