Michael Granger  committed b3ed74c

Fall back to 'http' scheme if running under a Mongrel2 that doesn't set the url-scheme header.

  • Participants
  • Parent commits 8aeffd8
  • Branches default

Comments (0)

Files changed (2)

File lib/mongrel2/httprequest.rb

 	### Convenience method for getting the request's 'url-scheme' header.
 	def scheme
-		return self.headers.url_scheme
+		return self.headers.url_scheme || 'http'

File spec/mongrel2/httprequest_spec.rb

 		@req.scheme.should == 'http'
+	it "falls back to 'http' if the url_scheme isn't provided (mongrel2 <= 1.8.0)" do
+		@req.headers.url_scheme = nil
+		@req.scheme.should == 'http'
+	end
 	it "knows that it was an SSL-encrypted request if its scheme was 'https'" do
 		@req.headers.url_scheme = 'https'
 		@req.should be_secure()