Exemplo n.º 1
0
 def _test_url(original_url, rewritten_url, env={}):
     self._set_env(env)
     request = QgsFcgiServerRequest()
     self.assertEqual(request.originalUrl().toString(), original_url)
     self.assertEqual(request.url().toString(), rewritten_url)
     # Check MAP
     if 'QUERY_STRING' in env:
         map = {k.upper(): v[0] for k, v in parse_qs(
             env['QUERY_STRING']).items()}['MAP']
     else:
         map = {k.upper(): v[0] for k, v in parse_qs(
             urlparse(env['REQUEST_URI']).query).items()}['MAP']
     self.assertEqual(request.parameter('MAP'), map)
Exemplo n.º 2
0
 def _test_url(original_url, rewritten_url, env={}):
     self._set_env(env)
     request = QgsFcgiServerRequest()
     self.assertEqual(request.originalUrl().toString(), original_url)
     self.assertEqual(request.url().toString(), rewritten_url)
     # Check MAP
     if 'QUERY_STRING' in env:
         map = {k.upper(): v[0] for k, v in parse_qs(
             env['QUERY_STRING']).items()}['MAP']
     else:
         map = {k.upper(): v[0] for k, v in parse_qs(
             urlparse(env['REQUEST_URI']).query).items()}['MAP']
     self.assertEqual(request.parameter('MAP'), map)
Exemplo n.º 3
0
 def test_fcgiRequestBody(self):
     """Test request body"""
     data = '<Literal>+1</Literal>'
     self._set_env({
         'SERVER_NAME': 'www.myserver.com',
         'SERVICE': 'WFS',
         'REQUEST_BODY': data,
         'CONTENT_LENGTH': str(len(data)),
         'REQUEST_METHOD': 'POST',
     })
     request = QgsFcgiServerRequest()
     response = QgsBufferServerResponse()
     self.server.handleRequest(request, response)
     self.assertEqual(request.parameter('REQUEST_BODY'),
                      '<Literal>+1</Literal>')
Exemplo n.º 4
0
 def _test_url(url, env={}):
     for k in ('QUERY_STRING', 'REQUEST_URI', 'SERVER_NAME', 'SERVER_PORT', 'SCRIPT_NAME'):
         try:
             del os.environ[k]
         except KeyError:
             pass
         try:
             os.environ[k] = env[k]
         except KeyError:
             pass
     request = QgsFcgiServerRequest()
     self.assertEqual(request.url().toString(), url)
     # Check MAP
     if 'QUERY_STRING' in env:
         map = {k.upper(): v[0] for k, v in parse_qs(env['QUERY_STRING']).items()}['MAP']
     else:
         map = {k.upper(): v[0] for k, v in parse_qs(urlparse(env['REQUEST_URI']).query).items()}['MAP']
     self.assertEqual(request.parameter('MAP'), map)