Sha256: bc990d951b7c2785b63916f0c516d5ff04fe540da04454a3c991453dde554154

Contents?: true

Size: 821 Bytes

Versions: 4

Compression:

Stored size: 821 Bytes

Contents

#	This file is part of the "Utopia Framework" project, and is released under the MIT license.
#	Copyright 2010 Samuel Williams. All rights reserved.
#	See <utopia.rb> for licensing details.

class Rack::Request
	def url_with_path(path = "")
		url = scheme + "://"
		url << host

		if scheme == "https" && port != 443 || scheme == "http" && port != 80
			url << ":#{port}"
		end

		url << path
	end
end

class Rack::Response
	def do_not_cache!
		self["Cache-Control"] = "no-cache, must-revalidate"
		self["Expires"] = Time.now.httpdate
	end
	
	def cache!(duration = 3600)
		unless (self["Cache-Control"] || "").match(/no-cache/)
			self["Cache-Control"] = "public, max-age=#{duration}"
			self["Expires"] = (Time.now + duration).httpdate
		end
	end
	
	def content_type!(value)
		self["Content-Type"] = value.to_s
	end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
utopia-0.10.0 lib/utopia/extensions/rack.rb
utopia-0.9.61 lib/utopia/extensions/rack.rb
utopia-0.9.60 lib/utopia/extensions/rack.rb
utopia-0.9.59 lib/utopia/extensions/rack.rb