Removing the charset in Content-Type

Hey everyone

Is there a way to remove the charset= from the Content-Type response
header?

I’m using mongrel and it puts out a content-type like this for for
playlist files:

Content-Type: audio/x-scpls; charset=utf-8

I set the content type to ‘audio/x-scpls’, but mongrel tacks on the
;xxxxx

Everything after the ; causes problems with some web browsers when they
try to launch an external application, like Winamp.

Thanks for reading.

How are you setting the content-type? In the two ways I tried,
mongrel never added the charset…

  1. Setting headers[‘Content-Type’] in the rails action.

$ cat app/controllers/test_controller.rb
class TestController < ApplicationController
def test
headers[‘Content-Type’] = ‘audio/x-scpls’
render :text => ‘hi’, :layout => false
end
end
$ lwp-request -d -e http://localhost:3000/test

Content-Type: audio/x-scpls

  1. Serving a file and having DirHandler serve the file, and using
    DirHandler.add_mime_type to return the right mime-type.

$ cat config/mongrel.conf
DirHandler.add_mime_type ‘.pls’, ‘audio/x-scpls’
$ lwp-request -e http://localhost:3000/test.pls

Content-Type: audio/x-scpls

On Apr 19, 9:42 am, Brandon C. [email protected]

I’m setting it the exact same way you are, but it always appends ‘;
charset=utf8’ to the end of content-type if I don’t specify my own
charset.

I’m going to try #2 as well.

A few minutes ago I found that eliminating Cache-Control from the header
made things work perfectly in versions of IE < 7. So maybe I really
don’t have to mess with the charset but I will try your suggestion.

Thank you for the tip!

Eden Li wrote:

How are you setting the content-type? In the two ways I tried,
mongrel never added the charset…

  1. Setting headers[‘Content-Type’] in the rails action.

$ cat app/controllers/test_controller.rb
class TestController < ApplicationController
def test
headers[‘Content-Type’] = ‘audio/x-scpls’
render :text => ‘hi’, :layout => false
end
end
$ lwp-request -d -e http://localhost:3000/test

Content-Type: audio/x-scpls

  1. Serving a file and having DirHandler serve the file, and using
    DirHandler.add_mime_type to return the right mime-type.

$ cat config/mongrel.conf
DirHandler.add_mime_type ‘.pls’, ‘audio/x-scpls’
$ lwp-request -e http://localhost:3000/test.pls

Content-Type: audio/x-scpls

On Apr 19, 9:42 am, Brandon C. [email protected]

Sounds like you’ve nicked it. Just one last thing… it looks like
Rails 1.2.x is adding the charset= bit, mongrel isn’t. When I tested
it I was using 1.1.6. Trying the same thing in 1.2.3 shows the
charset= in the response headers.

On Apr 19, 4:02 pm, Brandon C. [email protected]

Ya, thats what I thought too. I started poking around in the rails code
and I think I saw thing in ActionController. I’m not sure it’s a big
deal anymore. I think it’s more likely that the lack of or presence of
certain values in the http header was causing my problem across
different browsers. I made a poor initial guess.

Eden Li wrote:

Sounds like you’ve nicked it. Just one last thing… it looks like
Rails 1.2.x is adding the charset= bit, mongrel isn’t. When I tested
it I was using 1.1.6. Trying the same thing in 1.2.3 shows the
charset= in the response headers.

On Apr 19, 4:02 pm, Brandon C. [email protected]