VirtualBox

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

Last change on this file since 90802 was 86974, checked in by vboxsync, 4 years ago

testmanager: Attempted python 3 upload fix. bugref:9788

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.7 KB
Line 
1# -*- coding: utf-8 -*-
2# $Id: webservergluecgi.py 86974 2020-11-25 14:38:52Z vboxsync $
3
4"""
5Test Manager Core - Web Server Abstraction Base Class.
6"""
7
8__copyright__ = \
9"""
10Copyright (C) 2012-2020 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: 86974 $"
30
31
32# Standard python imports.
33import cgitb;
34import os;
35import sys;
36import cgi;
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
86 def getBodyIoStreamBinary(self):
87 # Python 3: sys.stdin.read() returns a string. To get untranslated
88 # binary data we use the sys.stdin.buffer object instead.
89 return getattr(sys.stdin, 'buffer', sys.stdin);
90
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