HTTP Accept Header meaning

前端 未结 2 896
梦如初夏
梦如初夏 2020-12-13 17:35

When a browser\'s Accept request header says something like the following:

Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,ima         


        
2条回答
  •  没有蜡笔的小新
    2020-12-13 18:02

    No, if the quality parameter is missing q=1.0 is assumed:

    Each media-range MAY be followed by one or more accept-params, beginning with the "q" parameter for indicating a relative quality factor […] using the qvalue scale from 0 to 1 (section 3.9). The default value is q=1.

    So the given value is to be interpreted as: “application/xml, application/xhtml+xml, and image/png are the preferred media types, but if they don’t exist, then send the text/html entity (text/html;q=0.9), and if that doesn’t exist, then send the text/plain entity (text/plain;q=0.8), and if that doesn’t exist, send an entity with any other media type (*/*;q=0.5).”

提交回复
热议问题