'Resend a test HTTP request until a response is received.
The container may have started, but the webserver inside may take a
little while to start serving requests.
:param int port: The localhost port to which an HTTP request will be
sent.
:return: A ``Deferred`` which fires with the result of the first
successful HTTP request.'

def request_until_response(self, port):

    def send_request():
        '\n                                                Send    an    HTTP    request    in    a    loop    until    the    request    is    answered.\n                                                '
        response = request('GET', ('http://127.0.0.1:%d' % (port,)), persistent=False)
        def check_error(failure):
            '\n                                                                Catch    ConnectionRefused    errors    and    response    timeouts    and    return\n                                                                False    so    that    loop_until    repeats    the    request.\n\n                                                                Other    error    conditions    will    be    passed    down    the    errback    chain.\n                                                                '
            failure.trap(ConnectionRefusedError, ResponseNeverReceived)
            return False
        response.addErrback(check_error)
        return response
    return loop_until(reactor, send_request)
