method
content_type=
v5.1.7 -
Show latest stable
- Class:
ActionDispatch::Response
content_type=(content_type)public
Sets the HTTP content type.
# File actionpack/lib/action_dispatch/http/response.rb, line 226
def content_type=(content_type)
return unless content_type
new_header_info = parse_content_type(content_type.to_s)
prev_header_info = parsed_content_type_header
charset = new_header_info.charset || prev_header_info.charset
charset ||= self.class.default_charset unless prev_header_info.mime_type
set_content_type new_header_info.mime_type, charset
end Related methods
- Instance methods
- abort
- await_commit
- await_sent
- body
- body=
- body_parts
- charset
- charset=
- close
- code
- commit!
- committed?
- content_type
- content_type=
- cookies
- delete_header
- each
- get_header
- has_header?
- message
- prepare!
- reset_body!
- response_code
- send_file
- sending!
- sending?
- sending_file=
- sent!
- sent?
- set_header
- status=
- status_message
- to_a
- write
- Class methods
- create
- merge_default_headers
- new
- Private methods
-
assign_default_content_type_and_charset! -
before_committed -
before_sending -
build_buffer -
handle_no_content! -
munge_body_object -
parse_content_type -
parsed_content_type_header -
rack_response -
set_content_type