VirtualBox

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

Last change on this file since 101505 was 99875, checked in by vboxsync, 19 months ago

ValKit: pylint adjustments for PEP-594 (dead batteries)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.2 KB
Line 
1# -*- coding: utf-8 -*-
2# $Id: webservergluecgi.py 99875 2023-05-20 00:57:37Z vboxsync $
3
4"""
5Test Manager Core - Web Server Abstraction Base Class.
6"""
7
8__copyright__ = \
9"""
10Copyright (C) 2012-2023 Oracle and/or its affiliates.
11
12This file is part of VirtualBox base platform packages, as
13available from https://www.virtualbox.org.
14
15This program is free software; you can redistribute it and/or
16modify it under the terms of the GNU General Public License
17as published by the Free Software Foundation, in version 3 of the
18License.
19
20This program is distributed in the hope that it will be useful, but
21WITHOUT ANY WARRANTY; without even the implied warranty of
22MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23General Public License for more details.
24
25You should have received a copy of the GNU General Public License
26along with this program; if not, see <https://www.gnu.org/licenses>.
27
28The contents of this file may alternatively be used under the terms
29of the Common Development and Distribution License Version 1.0
30(CDDL), a copy of it is provided in the "COPYING.CDDL" file included
31in the VirtualBox distribution, in which case the provisions of the
32CDDL are applicable instead of those of the GPL.
33
34You may elect to license modified versions of this file under the
35terms and conditions of either the GPL or the CDDL or both.
36
37SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
38"""
39__version__ = "$Revision: 99875 $"
40
41
42# Standard python imports.
43import cgi; # pylint: disable=deprecated-module ## @todo these will be retired in python 3.13!
44import cgitb; # pylint: disable=deprecated-module ## @todo these will be retired in python 3.13!
45import os;
46import sys;
47
48# Validation Kit imports.
49from testmanager.core.webservergluebase import WebServerGlueBase;
50from testmanager import config;
51
52
53class WebServerGlueCgi(WebServerGlueBase):
54 """
55 CGI glue.
56 """
57 def __init__(self, sValidationKitDir, fHtmlOutput=True):
58 WebServerGlueBase.__init__(self, sValidationKitDir, fHtmlOutput);
59
60 if config.g_kfSrvGlueCgiTb is True:
61 cgitb.enable(format=('html' if fHtmlOutput else 'text'));
62
63 def getParameters(self):
64 return cgi.parse(keep_blank_values=True);
65
66 def getClientAddr(self):
67 return os.environ.get('REMOTE_ADDR');
68
69 def getMethod(self):
70 return os.environ.get('REQUEST_METHOD', 'POST');
71
72 def getLoginName(self):
73 return os.environ.get('REMOTE_USER', WebServerGlueBase.ksUnknownUser);
74
75 def getUrlScheme(self):
76 return 'https' if 'HTTPS' in os.environ else 'http';
77
78 def getUrlNetLoc(self):
79 return os.environ['HTTP_HOST'];
80
81 def getUrlPath(self):
82 return os.environ['REQUEST_URI'];
83
84 def getUserAgent(self):
85 return os.getenv('HTTP_USER_AGENT', '');
86
87 def getContentType(self):
88 return cgi.parse_header(os.environ.get('CONTENT_TYPE', 'text/html'));
89
90 def getContentLength(self):
91 return int(os.environ.get('CONTENT_LENGTH', 0));
92
93 def getBodyIoStream(self):
94 return sys.stdin;
95
96 def getBodyIoStreamBinary(self):
97 # Python 3: sys.stdin.read() returns a string. To get untranslated
98 # binary data we use the sys.stdin.buffer object instead.
99 return getattr(sys.stdin, 'buffer', sys.stdin);
100
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