What is the purpose of the “q” values in the HTTP “Accept” request header?

后端 未结 4 611
情歌与酒
情歌与酒 2020-12-24 06:46

I have made a http request using Firefox.Now the request header shows the following:

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


        
4条回答
  •  北海茫月
    2020-12-24 07:31

    The Accept header list is first split at , then at ; for additional parameters per entry. So, the list in your example splits down to text/html, application/xhtml+xml, application/xml;q=0.9 and */*;q=0.8. The q= parameter on each entry indicates to the server the degree of preference for that media-type. It defaults to its maximum value of 1, if it is missing (like in the first 2 entries). The last entry of */*;q=0.8 indicates to the server, that eventually any content-type would be acceptable but would be less preferable than the others listed. Otherwise, the server might decide to send no content at all, because the client would not "accept" it anyway.

提交回复
热议问题