'Fire an HTTP event.
Args:
http_method : The HTTP method
path : The HTTP path
content : The HTTP body
mock_request : Mocked request to pass to the event so it can get
content.
Returns:
A tuple of (code, response)
Raises:
KeyError If no event is found which will handle the path.'

@patch('twisted.web.http.Request')
@defer.inlineCallbacks
def trigger(self, http_method, path, content, mock_request, federation_auth=False):

    path = (self.prefix + path)
    mock_content = Mock()
    config = {'read.return_value': content}
    mock_content.configure_mock(**config)
    mock_request.content = mock_content
    mock_request.method = http_method
    mock_request.uri = path
    mock_request.getClientIP.return_value = '-'
    headers = {}
    if federation_auth:
        headers['Authorization'] = ['X-Matrix    origin=test,key=,sig=']
    mock_request.requestHeaders.getRawHeaders = mock_getRawHeaders(headers)
    mock_request.path = path
    try:
        mock_request.args = urlparse.parse_qs(path.split('?')[1])
        mock_request.path = path.split('?')[0]
        path = mock_request.path
    except:
        pass
    for (method, pattern, func) in self.callbacks:
        if (http_method != method):
            continue
        matcher = pattern.match(path)
        if matcher:
            try:
                args = [urllib.unquote(u).decode('UTF-8') for u in matcher.groups()]
                (code, response) = (yield func(mock_request, *args))
                defer.returnValue((code, response))
            except CodeMessageException as e:
                defer.returnValue((e.code, cs_error(e.msg, code=e.errcode)))
    raise KeyError(('No    event    can    handle    %s' % path))
