def _requestAgentTest(self, child, **kwargs):
    '\n        Set up a resource on a distrib site using L{ResourcePublisher} and\n        then retrieve it from a L{ResourceSubscription} via an HTTP client.\n\n        @param child: The resource to publish using distrib.\n        @param **kwargs: Extra keyword arguments to pass to L{Agent.request} when\n            requesting the resource.\n\n        @return: A L{Deferred} which fires with a tuple consisting of a\n            L{twisted.test.proto_helpers.AccumulatingProtocol} containing the\n            body of the response and an L{IResponse} with the response itself.\n        '
    (mainPort, mainAddr) = self._setupDistribServer(child)
    url = 'http://{}:{}/child'.format(mainAddr.host, mainAddr.port)
    url = url.encode('ascii')
    d = client.Agent(reactor).request(b'GET', url, **kwargs)

    def cbCollectBody(response):
        protocol = proto_helpers.AccumulatingProtocol()
        response.deliverBody(protocol)
        d = protocol.closedDeferred = defer.Deferred()
        d.addCallback((lambda _: (protocol, response)))
        return d
    d.addCallback(cbCollectBody)
    return d
Set up a resource on a distrib site using L{ResourcePublisher} and
then retrieve it from a L{ResourceSubscription} via an HTTP client.

@param child: The resource to publish using distrib.
@param **kwargs: Extra keyword arguments to pass to L{Agent.request} when
    requesting the resource.

@return: A L{Deferred} which fires with a tuple consisting of a
    L{twisted.test.proto_helpers.AccumulatingProtocol} containing the
    body of the response and an L{IResponse} with the response itself.
def _requestAgentTest(self, child, **kwargs):
    '\n        Set up a resource on a distrib site using L{ResourcePublisher} and\n        then retrieve it from a L{ResourceSubscription} via an HTTP client.\n\n        @param child: The resource to publish using distrib.\n        @param **kwargs: Extra keyword arguments to pass to L{Agent.request} when\n            requesting the resource.\n\n        @return: A L{Deferred} which fires with a tuple consisting of a\n            L{twisted.test.proto_helpers.AccumulatingProtocol} containing the\n            body of the response and an L{IResponse} with the response itself.\n        '
    (mainPort, mainAddr) = self._setupDistribServer(child)
    url = 'http://{}:{}/child'.format(mainAddr.host, mainAddr.port)
    url = url.encode('ascii')
    d = client.Agent(reactor).request(b'GET', url, **kwargs)

    def cbCollectBody(response):
        protocol = proto_helpers.AccumulatingProtocol()
        response.deliverBody(protocol)
        d = protocol.closedDeferred = defer.Deferred()
        d.addCallback((lambda _: (protocol, response)))
        return d
    d.addCallback(cbCollectBody)
    return d