Class: Rack::ContentType
| Relationships & Source Files | |
| Super Chains via Extension / Inclusion / Inheritance | |
|
Instance Chain:
self,
Utils
|
|
| Inherits: | Object |
| Defined in: | lib/rack/content_type.rb |
Overview
Constant Summary
Utils - Included
COMMON_SEP, DEFAULT_SEP, HTTP_STATUS_CODES, InvalidParameterError, KeySpaceConstrainedParams, NULL_BYTE, OBSOLETE_SYMBOLS_TO_STATUS_CODES, OBSOLETE_SYMBOL_MAPPINGS, PATH_SEPS, ParameterTypeError, ParamsTooDeepError, STATUS_WITH_NO_ENTITY_BODY, SYMBOL_TO_STATUS_CODE, URI_PARSER, VALID_COOKIE_KEY
Class Method Summary
Instance Method Summary
Utils - Included
| #best_q_match | Return best accept value to use, based on the algorithm in RFC 2616 Section 14. |
| #build_nested_query, #build_query, | |
| #byte_ranges | Parses the “Range:” header, if present, into an array of Range objects. |
| #clean_path_info, | |
| #clock_time | :nocov: |
| #delete_cookie_header!, | |
| #delete_set_cookie_header | Generate an encoded string based on the given |
| #delete_set_cookie_header! | Set an expired cookie in the specified headers with the given cookie |
| #escape | URI escapes. |
| #escape_html | Escape ampersands, brackets and quotes to their HTML/XML entities. |
| #escape_path | Like URI escaping, but with %20 instead of +. |
| #forwarded_values, #get_byte_ranges, | |
| #parse_cookies | Parse cookies from the provided request environment using parse_cookies_header. |
| #parse_cookies_header | Parse cookies from the provided header |
| #parse_nested_query, #parse_query, #q_values, #rfc2822, | |
| #secure_compare | Constant time string comparison. |
| #select_best_encoding, | |
| #set_cookie_header | Generate an encoded string using the provided |
| #set_cookie_header! | Append a cookie in the specified headers with the given cookie |
| #status_code, | |
| #unescape | Unescapes a URI escaped string with |
| #unescape_path | Unescapes the path component of a URI. |
| #valid_path? | |
Constructor Details
.new(app, content_type = "text/html") ⇒ ContentType
# File 'lib/rack/content_type.rb', line 18
def initialize(app, content_type = "text/html") @app = app @content_type = content_type end
Instance Method Details
#call(env)
[ GitHub ]# File 'lib/rack/content_type.rb', line 23
def call(env) status, headers, _ = response = @app.call(env) unless STATUS_WITH_NO_ENTITY_BODY.key?(status.to_i) headers[CONTENT_TYPE] ||= @content_type end response end