rack-devel archive mirror (unofficial) https://groups.google.com/group/rack-devel
 help / color / mirror / Atom feed
* Suggestion: Uppercase extensions should be downcased
@ 2009-06-20 10:27 Lars Olsson
  2009-06-23 13:45 ` Michael Fellinger
  0 siblings, 1 reply; 3+ messages in thread
From: Lars Olsson @ 2009-06-20 10:27 UTC (permalink / raw)
  To: rack-devel


Hello!

While working with some files created on Windows in Ramaze i discoved
that the web server returned the wrong content-type in some cases. I
tracked this down to the mime_type function in rack.

(from file rack/lib/rack/mime.rb)
def mime_type(ext, fallback='application/octet-stream')
    MIME_TYPES.fetch(ext, fallback)
end

This gives me trouble when the file extension includes uppercase letters
as nothing in MIME_TYPES is matching. I think the code should be changed to:

def mime_type(ext, fallback='application/octet-stream')
    MIME_TYPES.fetch(ext.downcase, fallback)
end

which makes extensions like .JPG work again.


Sincerely yours

/lasso

-- 
________________________________________
Lars Olsson
lasso@lassoweb.se
http://www.lassoweb.se/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Suggestion: Uppercase extensions should be downcased
  2009-06-20 10:27 Suggestion: Uppercase extensions should be downcased Lars Olsson
@ 2009-06-23 13:45 ` Michael Fellinger
  2009-06-23 18:40   ` Lars Olsson
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Fellinger @ 2009-06-23 13:45 UTC (permalink / raw)
  To: rack-devel


On Sat, Jun 20, 2009 at 7:27 PM, Lars Olsson<lasso@lassoweb.se> wrote:
>
> Hello!
>
> While working with some files created on Windows in Ramaze i discoved
> that the web server returned the wrong content-type in some cases. I
> tracked this down to the mime_type function in rack.
>
> (from file rack/lib/rack/mime.rb)
> def mime_type(ext, fallback='application/octet-stream')
>    MIME_TYPES.fetch(ext, fallback)
> end
>
> This gives me trouble when the file extension includes uppercase letters
> as nothing in MIME_TYPES is matching. I think the code should be changed to:
>
> def mime_type(ext, fallback='application/octet-stream')
>    MIME_TYPES.fetch(ext.downcase, fallback)
> end
>
> which makes extensions like .JPG work again.

OK, pushed a patch for that.

--
^ manveru

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Suggestion: Uppercase extensions should be downcased
  2009-06-23 13:45 ` Michael Fellinger
@ 2009-06-23 18:40   ` Lars Olsson
  0 siblings, 0 replies; 3+ messages in thread
From: Lars Olsson @ 2009-06-23 18:40 UTC (permalink / raw)
  To: Rack Development


On 23 Juni, 15:45, Michael Fellinger <m.fellin...@gmail.com> wrote:
> On Sat, Jun 20, 2009 at 7:27 PM, Lars Olsson<la...@lassoweb.se> wrote:
>
> > Hello!
>
> > While working with some files created on Windows in Ramaze i discoved
> > that the web server returned the wrong content-type in some cases. I
> > tracked this down to the mime_type function in rack.
>
> > (from file rack/lib/rack/mime.rb)
> > def mime_type(ext, fallback='application/octet-stream')
> >    MIME_TYPES.fetch(ext, fallback)
> > end
>
> > This gives me trouble when the file extension includes uppercase letters
> > as nothing in MIME_TYPES is matching. I think the code should be changed to:
>
> > def mime_type(ext, fallback='application/octet-stream')
> >    MIME_TYPES.fetch(ext.downcase, fallback)
> > end
>
> > which makes extensions like .JPG work again.
>
> OK, pushed a patch for that.
>
> --
> ^ manveru

Thanks!

/lasso

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-06-23 19:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-20 10:27 Suggestion: Uppercase extensions should be downcased Lars Olsson
2009-06-23 13:45 ` Michael Fellinger
2009-06-23 18:40   ` Lars Olsson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).