From: Samuel Lebeau <samuel.lebeau@gmail.com>
To: Rack Development <rack-devel@googlegroups.com>
Subject: Rack::JSONP breaks Rack::Mime by mutating content type
Date: Thu, 12 Aug 2010 09:22:03 -0700 (PDT) [thread overview]
Message-ID: <e83047fa-bc18-40a9-9d8d-7401491d5010@j8g2000yqd.googlegroups.com> (raw)
Hello,
I've filed a ticket on Github [1] but realized later that the
preferred way is to post a message here.
Here is the issue: `Rack::JSONP` uses `gsub!` to change content type,
which has the disastrous effect of altering
`Rack::Mime::MIME_TYPES['.json']`.
Say you're using Sinatra, with `content_type :json` in some route's
block, it looks up `MIME_TYPES` under the hood, which is then mutated
by `JSONP`: subsequent requests are then served as javascript and are
ignored by the middleware.
IMHO it should use `gsub` instead (I can see no reason for Sinatra to
duplicate the mime type upstream), and `Rack::Mime::MIME_TYPES` could
even `freeze` its content type strings to prevent this kind of errors.
I've made a patch on my fork, I hope this will be useful [2].
Best,
Samuel.
[1] http://github.com/rack/rack-contrib/issues/9
[2] http://github.com/samleb/rack-contrib/commit/2921c9e78b6c473d5d42162a2c33ac90773ce291
reply other threads:[~2010-08-12 16:52 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://groups.google.com/group/rack-devel
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e83047fa-bc18-40a9-9d8d-7401491d5010@j8g2000yqd.googlegroups.com \
--to=rack-devel@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).