~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to lib/common/cgirequest.py

  • Committer: mattgiuca
  • Date: 2008-06-23 12:19:28 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:791
fileservice_lib/action.py: Fixed regression.
    File upload was partially fixed but broken. Now upload should work again!

Show diffs side-by-side

added added

removed removed

Lines of Context:
123
123
 
124
124
        if ('SERVER_NAME' not in os.environ or
125
125
            'REQUEST_METHOD' not in os.environ or
126
 
            'REQUEST_URI' not in os.environ):
 
126
            'SCRIPT_NAME' not in os.environ or
 
127
            'PATH_INFO' not in os.environ):
127
128
            raise Exception("No CGI environment found")
128
129
 
129
130
        # Determine if the browser used the public host name to make the
135
136
 
136
137
        # Inherit values for the input members
137
138
        self.method = os.environ['REQUEST_METHOD']
138
 
        self.uri = os.environ['REQUEST_URI']
 
139
        self.uri = os.environ['SCRIPT_NAME'] + os.environ['PATH_INFO']
139
140
        # Split the given path into the app (top-level dir) and sub-path
140
141
        # (after first stripping away the root directory)
141
142
        path = common.util.unmake_path(self.uri)
142
143
        if self.publicmode:
143
144
            self.app = None
144
 
            self.path = path
 
145
            (_, self.path) = (common.util.split_path(path))
145
146
        else:
146
147
            (self.app, self.path) = (common.util.split_path(path))
147
 
        self.username = None
 
148
        self.user = None
148
149
        self.hostname = os.environ['SERVER_NAME']
149
150
        self.headers_in = _http_headers_in_from_cgi()
150
151
        self.headers_out = {}
242
243
        else:
243
244
            return sys.stdin.read(len)
244
245
 
245
 
    def throw_error(self, httpcode):
 
246
    def throw_error(self, httpcode, message):
246
247
        """Writes out an HTTP error of the specified code. Exits the process,
247
248
        so any code following this call will not be executed.
248
249
 
253
254
        httpcode: An HTTP response status code. Pass a constant from the
254
255
        Request class.
255
256
        """
256
 
        self.status = httpcode
257
 
        self.content_type = "text/html"
258
 
        # Emulate an Apache error
259
 
        self.write("""<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
260
 
<html><head>
261
 
<title>%d Error</title>
262
 
</head><body>
263
 
<h1>Error</h1>
264
 
<p>A %d error was triggered by a CGI app.</p>
265
 
</body></html>
266
 
""" % (httpcode, httpcode))
267
 
        # Exit the process completely
268
 
        self.flush()
269
 
        sys.exit(httpcode)
 
257
        raise common.util.IVLEError(httpcode, message)
270
258
 
271
259
    def throw_redirect(self, location):
272
260
        """Writes out an HTTP redirect to the specified URL. Exits the