How !isset in Ruby

A

Alexey Tafintsev

Ravil - Thank you very much!
Working example Ruby CGI Basic Authorization

---------------------------------------
Add this in you .htaccess
RewriteEngine on
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule ^(.*) - [E=HTTP_CGI_AUTHORIZATION:%1]
---------------------------------------
#!c:/ruby/bin/ruby.exe

$kcode = "windows-1251"

require 'cgi'

cgi = CGI.new 'html4'
auth_type, credentials = ENV['HTTP_CGI_AUTHORIZATION'].split(' ')

if auth_type == 'Basic' && (user, pass =
credentials.unpack('m*').first.split(':', 2)) && user == 'test' && pass
= 'test'
cgi.out {
cgi.html {
cgi.body {
cgi.h2 { "Login: #{user}" } +
cgi.h2 { "Pass: #{pass}" }
}
}
}
else
cgi.out("Status" => "401 Authorization Required", "Type" =>
"text/html", "WWW-Authenticate" => 'Basic realm="Web Password"') do
"401 Authorization Required"
end
end
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top