LoginSignup
5
6

More than 1 year has passed since last update.

Content-Type: application/jsonとはそもそも何なのか

Posted at

Content-Typeとは

  • リソースのメディア種別を示すために使用する
  • レスポンスにおいては、 クライアントに返されたコンテンツの実際の種類を伝える
  • リクエストにおいては クライアントがサーバーに実際に送ったデータの種類を伝える
  • タイプ/サブタイプの形で表現される

Content-Typeを指定しない場合、どうなるのか

推測してContent-Typeを決める。
よって、意図した形式でデータをやりとりできるように、Content-Typeを定めた方が良い。

application/jsonとは

jsonフォーマットでデータが送信される。

例えば、以下のような形。

{"Name": "John Smith", "Age": 23}

補足:application/x-www-form-urlencodedとは

以下のようにエンコードされて送信される。

Name=John+Smith&Age=23

参考

https://developer.mozilla.org/ja/docs/Web/HTTP/Headers/Content-Type
https://portswigger.net/kb/issues/00800500_content-type-is-not-specified#:~:text=If%20a%20response%20does%20not,or%20other%20client%2Dside%20vulnerabilities.
https://stackoverflow.com/questions/9870523/what-are-the-differences-between-application-json-and-application-x-www-form-url

5
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
6