What is and why is there a difference between request.env ['CONTENT_TYPE'] and request.content_type?

I see two different values ​​for request.env['CONTENT_TYPE']and request.content_type.

In a separate application, I submit a request to my Rails application and explicitly install Content-Typein text/xml.

Here is what I see at the other end, from my Rails application:

request.env['CONTENT_TYPE'] = "text/xml"
request.content_type = "application/xml"

request.content_type in fact action_dispatch.request.content_type

  • What is the difference between request.env['CONTENT_TYPE']and request.content_type?
  • Why are these two meanings different?
+3
source share
1 answer

request.envcontains “thoughts” about what a content type is. This is usually the type of content of the request you requested.

request.content_type, , Rails , , . mime_types.rb Rails ( , , ), config/initializers/mime_types.rb.

+5

Source: https://habr.com/ru/post/1789184/


All Articles