Are HTTP headers case-sensitive?

后端 未结 8 2280
梦如初夏
梦如初夏 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:33

    the Headers word are not case sensitive, but on the right like the Content-Type, is good practice to write it this way, because its case sensitve. like my example below

    headers = headers.set('Content-Type'
    
    0 讨论(0)
  • 2020-11-22 03:34

    They are not case sensitive. In fact NodeJS web server explicitly converts them to lower-case, before making them available in the request object.

    It's important to note here that all headers are represented in lower-case only, regardless of how the client actually sent them. This simplifies the task of parsing headers for whatever purpose.

    0 讨论(0)
提交回复
热议问题