7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/ape/handler.rb', line 7
def process(request, response)
cgi = Mongrel::CGIWrapper.new(request, response)
uri = cgi['uri'].strip
user = cgi['username'].strip
pass = cgi['password'].strip
if uri.empty?
response.start(200, true) do |, body|
['Content-Type'] = 'text/plain'
body << 'URI argument is required'
end
return
end
format = request.params['HTTP_ACCEPT'] == 'text/plain' ? 'text' : 'html'
ape = Ape.new({ :crumbs => true, :output => format })
(user && pass) ? ape.check(uri, user, pass) : ape.check(uri)
response.start(200, true) do |, body|
['Content-Type'] = 'text/html'
ape.report(body)
end
end
|