/usr/share/pyshared/albatross/cgiapp.py is in python-albatross 1.36-5.5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | #
# Copyright 2001 by Object Craft P/L, Melbourne, Australia.
#
# LICENCE - see LICENCE file distributed with this software for details.
#
import cgi
import sys
import os
from albatross.common import *
from albatross.request import RequestBase
class Request(RequestBase):
def __init__(self, fields = None):
if fields is None:
fields = cgi.FieldStorage()
RequestBase.__init__(self, fields)
def get_param(self, name, default=None):
return os.environ.get(name, default)
def get_uri(self):
return self.get_param('REQUEST_URI')
def get_method(self):
return self.get_param('REQUEST_METHOD')
def get_path_info(self):
return self.get_param('PATH_INFO')
def get_servername(self):
return self.get_param('HTTP_HOST')
def get_header(self, name):
env_name = 'HTTP_' + name.upper().replace('-', '_')
return self.get_param(env_name)
def write_header(self, name, value):
sys.stdout.write('%s: %s\n' % (name, value))
def end_headers(self):
status = self.status()
if status != HTTP_OK:
self.write_header('Status', http_status_string(status))
sys.stdout.write('\n')
def redirect(self, loc):
self.set_status(HTTP_MOVED_PERMANENTLY)
self.write_header('Location', loc)
self.end_headers()
def write_content(self, data):
sys.stdout.write(data)
sys.stdout.flush()
|