Header parameters: “Accept” and “Content-type” in a REST context

后端 未结 4 453
猫巷女王i
猫巷女王i 2020-12-08 07:03

I understand that the Accept parameter define a data type expected in a client response sent from the server, so it\'s used as a response header.

My que

4条回答
  •  离开以前
    2020-12-08 07:18

    Read the relevant RFCs. In this case 7231:

    5.3.2. Accept

    The "Accept" header field can be used by user agents to specify response media types that are acceptable.


    3.1.1.5. Content-Type

    The "Content-Type" header field indicates the media type of the associated representation

    So: Accept indicates what kind of response from the server the client can accept. Content-type always is about the content of the current request or response.

    So if your request has no payload, you don't use a content-type request header.

提交回复
热议问题