Are HTTP headers case-sensitive?

后端 未结 8 2360
梦如初夏
梦如初夏 2020-11-22 03:03

In a blog post I use the following PHP to set the content-type of a response:

header(\'content-type: application/json; charset=utf-8\');

I

8条回答
  •  深忆病人
    2020-11-22 03:22

    The RFC for HTTP (as cited above) dictates that the headers are case-insensitive, however you will find that with certain browsers (I'm looking at you, IE) that capitalizing each of the words tends to be best:

    Location: http://stackoverflow.com
    
    Content-Type: text/plain
    

    vs

    location: http://stackoverflow.com
    
    content-type: text/plain
    

    This isn't "HTTP" standard, but just another one of the browser quirks, we as developers, have to think about.

提交回复
热议问题