def testEnvironEqualsError(self):
   self.StartWebServer(filters.environ_equals('HTTP_X', 'blar'))
   self.CheckError('/', headers={'x': 'a thing'})
示例#2
0
        except Exception, err:
            response_app = protorpc_response(
                remote.RpcStatus(state=remote.RpcState.SERVER_ERROR,
                                 error_message='Internal Server Error'),
                protocol=request_protocol.protocol,
                status=(500, 'Internal Server Error'))
            return response_app(environ, start_response)

        start_response(
            '200 OK', [('content-type', request_protocol.default_content_type),
                       ('content-length', str(len(encoded_response)))])
        return [encoded_response]

    application = service_app_application

    # Must be POST.
    application = filters.environ_equals(
        'REQUEST_METHOD',
        'POST',
        app=application,
        on_error=filters.HTTP_METHOD_NOT_ALLOWED)

    # Match protocol based on content-type.
    application = match_protocol(application, protocols)

    # Must match request path.  Parses out actual service-path.  A non-match is
    # akin to a 404 by default.  Will pass through to next application on miss.
    application = match_method(service_path, app=application, on_error=app)

    return application
 def testEnvironEquals(self):
   self.StartWebServer(filters.environ_equals('HTTP_X', 'a thing'))
   response = self.SendRequest('/', headers={'x': 'a thing'})
   self.CheckResponse(response, expected_content='')