VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/testmanager/core/webservergluecgi.py@ 63694

Last change on this file since 63694 was 62484, checked in by vboxsync, 8 years ago

(C) 2016

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.5 KB
Line 
1# -*- coding: utf-8 -*-
2# $Id: webservergluecgi.py 62484 2016-07-22 18:35:33Z vboxsync $
3
4"""
5Test Manager Core - Web Server Abstraction Base Class.
6"""
7
8__copyright__ = \
9"""
10Copyright (C) 2012-2016 Oracle Corporation
11
12This file is part of VirtualBox Open Source Edition (OSE), as
13available from http://www.virtualbox.org. This file is free software;
14you can redistribute it and/or modify it under the terms of the GNU
15General Public License (GPL) as published by the Free Software
16Foundation, in version 2 as it comes in the "COPYING" file of the
17VirtualBox OSE distribution. VirtualBox OSE is distributed in the
18hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
19
20The contents of this file may alternatively be used under the terms
21of the Common Development and Distribution License Version 1.0
22(CDDL) only, as it comes in the "COPYING.CDDL" file of the
23VirtualBox OSE distribution, in which case the provisions of the
24CDDL are applicable instead of those of the GPL.
25
26You may elect to license modified versions of this file under the
27terms and conditions of either the GPL or the CDDL or both.
28"""
29__version__ = "$Revision: 62484 $"
30
31
32# Standard python imports.
33import cgi;
34import cgitb;
35import os;
36import sys;
37
38# Validation Kit imports.
39from testmanager.core.webservergluebase import WebServerGlueBase;
40from testmanager import config;
41
42
43class WebServerGlueCgi(WebServerGlueBase):
44 """
45 CGI glue.
46 """
47 def __init__(self, sValidationKitDir, fHtmlOutput=True):
48 WebServerGlueBase.__init__(self, sValidationKitDir, fHtmlOutput);
49
50 if config.g_kfSrvGlueCgiTb is True:
51 cgitb.enable(format=('html' if fHtmlOutput else 'text'));
52
53 def getParameters(self):
54 return cgi.parse(keep_blank_values=True);
55
56 def getClientAddr(self):
57 return os.environ.get('REMOTE_ADDR');
58
59 def getMethod(self):
60 return os.environ.get('REQUEST_METHOD', 'POST');
61
62 def getLoginName(self):
63 return os.environ.get('REMOTE_USER', WebServerGlueBase.ksUnknownUser);
64
65 def getUrlScheme(self):
66 return 'https' if 'HTTPS' in os.environ else 'http';
67
68 def getUrlNetLoc(self):
69 return os.environ['HTTP_HOST'];
70
71 def getUrlPath(self):
72 return os.environ['REQUEST_URI'];
73
74 def getUserAgent(self):
75 return os.getenv('HTTP_USER_AGENT', '');
76
77 def getContentType(self):
78 return cgi.parse_header(os.environ.get('CONTENT_TYPE', 'text/html'));
79
80 def getContentLength(self):
81 return int(os.environ.get('CONTENT_LENGTH', 0));
82
83 def getBodyIoStream(self):
84 return sys.stdin;
85
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette