From: marios <[email protected]>
---
server/lib/sinatra/respond_to.rb | 39 +++++++------------------------------
1 files changed, 8 insertions(+), 31 deletions(-)
diff --git a/server/lib/sinatra/respond_to.rb b/server/lib/sinatra/respond_to.rb
index f88c025..926b10d 100644
--- a/server/lib/sinatra/respond_to.rb
+++ b/server/lib/sinatra/respond_to.rb
@@ -30,38 +30,15 @@ module Sinatra
app.set :default_content, :html
app.set :assume_xhr_is_js, true
- # We remove the trailing extension so routes
- # don't have to be of the style
- #
- # get '/resouce.:format'
- #
- # They can instead be of the style
- #
- # get '/resource'
- #
- # and the format will automatically be available in <tt>format</tt>
+ #deltacloud: removed the code that tried to 'guess' content based on
extension
+ #as this broke blobstore api (stripping blob names). Use ?format if
present, otherwise
+ #use http accept, otherwise set to default
app.before do
- # Let through sinatra image urls in development
- next if self.class.development? && request.path_info =~
%r{/__sinatra__/.*?.png}
-
- unless options.static? && options.public? && (request.get? ||
request.head?) && static_file?(request.path_info)
- rpi = request.path_info.sub(%r{\.([^\./]+)$}, '')
-
- if (not $1) or ($1 and TEXT_MIME_TYPES.include?($1.to_sym))
- request.path_info, ext = rpi, nil
- if ! $1.nil?
- ext = $1
- elsif env['HTTP_ACCEPT'].nil? || env['HTTP_ACCEPT'].empty?
- ext = options.default_content
- end
- if ext
- @mime_types = [ Helpers::mime_type(ext) ]
- format ext
- elsif (params[:format])
- @mime_types = [Helpers::mime_type(params[:format])]
- format params[:format]
- end
- end
+ if (params[:format])
+ @mime_types = [Helpers::mime_type(params[:format])]
+ format params[:format]
+ elsif env['HTTP_ACCEPT'].nil? || env['HTTP_ACCEPT'].empty?
+ ext = options.default_content
end
end
--
1.7.2.3