Exemplo n.º 1
0
  def testMatch(self):
    self.StartWebServer(filters.match_environ(
      'HTTP_X', r'exact', app=filters.static_page('it was ok')))

    response = self.SendRequest('/', headers={'x': 'exact'})
    self.CheckResponse(response, expected_content='it was ok')

    response = self.SendRequest('/', headers={'x': 'exact not so much'})
    self.CheckResponse(response, expected_content='it was ok')
Exemplo n.º 2
0
  def testMatchGroups(self):
    def application(environ, start_response):
      content = '%s %s %s' % (environ['HTTP_X.0'],
                              environ['HTTP_X.1'],
                              environ.get('HTTP_X.2') is None)
      return filters.static_page(content)(environ, start_response)

    self.StartWebServer(
      filters.match_environ('HTTP_X', '(left)-(right)', app=application))

    response = self.SendRequest('/', headers={'x': 'left-right'})
    self.CheckResponse(response, expected_content='left right True')
Exemplo n.º 3
0
  def testNoMatch(self):
    self.StartWebServer(filters.match_environ(
      'HTTP_X', r'None', app=filters.static_page('it was ok')))

    self.CheckError('/')
    self.CheckError('/', headers={'x': 'not a match'})