This project is archived and is in readonly mode.

#2564 ✓resolved
Michael Schuerig

AC::Request#content_type should return a string

Reported by Michael Schuerig | April 25th, 2009 @ 07:37 PM | in 2.x

Today, I git pulled rails 2-3-stable and (inadvertently) updated rack to 1.0.0, therefore I can definitely tell who's at fault, it might even be me. Anyway, Rack::Request#media_type expects #content_type to return a string which it may not always do in its current incarnation. Below I've added in the tiny #to_s

ActionController::Request < Rack::Request

    def content_type
      @content_type ||= begin
        if @env['CONTENT_TYPE'] =~ /^([^,\;]*)/

This issue may affect other code at the intersection of ActionController and Rack. ActionController uses Mime::Type objects freely, but Rack doesn't know about them.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>