Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

34 lines (28 sloc) 1.046 kb
require File.dirname(__FILE__) + '/helper'
class RequestTest < Test::Unit::TestCase
it 'responds to #user_agent' do
request = Sinatra::Request.new({'HTTP_USER_AGENT' => 'Test'})
assert request.respond_to?(:user_agent)
assert_equal 'Test', request.user_agent
end
it 'parses POST params when Content-Type is form-dataish' do
request = Sinatra::Request.new(
'REQUEST_METHOD' => 'PUT',
'CONTENT_TYPE' => 'application/x-www-form-urlencoded',
'rack.input' => StringIO.new('foo=bar')
)
assert_equal 'bar', request.params['foo']
end
it 'is secure when the url scheme is https' do
request = Sinatra::Request.new('rack.url_scheme' => 'https')
assert request.secure?
end
it 'is not secure when the url scheme is http' do
request = Sinatra::Request.new('rack.url_scheme' => 'http')
assert !request.secure?
end
it 'respects X-Forwarded-Proto header for proxied SSL' do
request = Sinatra::Request.new('HTTP_X_FORWARDED_PROTO' => 'https')
assert request.secure?
end
end
Jump to Line
Something went wrong with that request. Please try again.